I have a similar issue. Note that some of links above are broken. I read and applied the fixes myself. I also went into the js-algorand-sdk to look at what the SDK does and even following that I get a 400 malformed request error.
I want to send a transaction to the algoexplorer endpoint for broadcast. Specifically: first an opt-in transaction, and then normal transactions to move assets.
@pipaman, that file contains no POST request for the /v2/transactions or even the /transactions endpoint whereas you can find the /v2/transaction endpoint here: AlgoExplorer API v2
I am building an application that will go live soon, I’d appreciate if the community can help me sort this out in a timely manner. Thank you.
@NHamilton, I need some help. 
Sample code:
>`// Get the mainnet recommended parameters for transactions
const algoApiParams = axios.create({baseURL: "https://algoexplorerapi.io/",
timeout: 1000,
headers: {"accept": "application/json"},
});
return algoApiParams.get( "v2/transactions/params" )
.then( (parms: any) => {
const assetID = 123456789; //Just a dummy assetID for posting here
const params = parms.data;
const parameters = {
"fee": 1000,
"flatFee": true,
"genesisHash": params["genesis-hash"],
"lastRound": params["last-round"] + 10,
"genesisID": params["genesis-id"],
"firstRound": params["last-round"] - 10,
};
const sender = wallet;
const recipient = wallet;
const revocationTarget = undefined;
const closeRemainderTo = undefined;
const amount = 0;
const note = undefined;
const opttxn = algosdk.makeAssetTransferTxnWithSuggestedParams(
sender,
recipient,
closeRemainderTo,
revocationTarget,
amount,
note,
assetID,
parameters);
const rawSignedTxn = algosdk.signTransaction( opttxn, pkey );
// Send the transaction
const algoApiBroadcastTxn = axios.create({baseURL: "https://algoexplorerapi.io/",
timeout: 1000,
headers: { 'accept': 'application/json',
"Content-Type": "application/x-binary"},
});
return algoApiBroadcastTxn.post("v2/transactions/",
rawSignedTxn.blob )
.then( (res2) => {
console.log(res2);
return res2;
})
.catch( (err) =>{
console.log("POST error message: ", err);
return err;
});
}).catch( (err) => {
console.log(err);
return err ;
});
`
Error Message:
POST error message: Error: Request failed with status code 400
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [Function: httpAdapter],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 1000,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
headers: {
Accept: 'application/json',
'Content-Type': 'application/x-binary',
'User-Agent': 'axios/0.23.0',
'Content-Length': 251
},
baseURL: 'https://algoexplorerapi.io/',
method: 'post',
url: 'v2/transactions/',
data: ArrayBuffer {
[Uint8Contents]: <82 a3 73 69 67 c4 40 d7 99 d5 1b 22 bf 2f 15 04 ad 6d b1 5c 92 a4 ce 32 ef c0 63 6f 10 24 dd 4f 64 8c 9b 04 0c 1c 88 75 22 85 5c fa c5 e4 75 22 35 2d 92 13 db ee fb 79 08 78 cb a7 a5 5e c2 4d d2 dc 11 31 c9 8c 05 a3 74 78 6e 89 a4 61 72 63 76 c4 20 74 97 9c 73 de 18 35 f6 85 8a cf d2 de 86 67 ca 7c ... 151 more bytes>,
byteLength: 251
}
}
data: {
message: 'TransactionPool.Remember: transaction T5WT3L576AOZO6OIN4MDP3M7H6XI5J5CK4BFZNOUDJESWGAYQ4MA: overspend (account OSLZY466DA27NBMKZ7JN5BTHZJ6NY652WYTA4EHYXQ4TMFSMBJGYRO5RIE, data {_struct:{} Status:Offline MicroAlgos:{Raw:0} RewardsBase:0 RewardedMicroAlgos:{Raw:0} VoteID:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] SelectionID:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] VoteFirstValid:0 VoteLastValid:0 VoteKeyDilution:0 AssetParams:map[] Assets:map[] AuthAddr:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ AppLocalStates:map[] AppParams:map[] TotalAppSchema:{_struct:{} NumUint:0 NumByteSlice:0} TotalExtraAppPages:0}, tried to spend {1000})'
}
I omitted part of the error response as it is not relevant.