Error in getting transaction params using purestack api it shows a 400 status error its on testnet

Hi,
I am getting a issue like this:

{"status":400,"response":{"req":{"method":"GET","url":"https://testnet-algorand.api.purestake.io/idx2/v2/transactions/params","headers":{"x-api-key":"My perfectly correct key","accept":"application/json"}},"header":{"content-type":"application/json","content-length":"108","connection":"close","date":"Tue, 08 Jun 2021 02:58:56 GMT","x-amzn-requestid":"2b3f9683-8efd-427a-970d-f8258dde7c85","x-amz-apigw-id":"Ald1lFSsYosFkvA=","x-amzn-trace-id":"Root=1-60bedcf0-46f5704b122ef65741404d0b","x-cache":"Error from cloudfront","via":"1.1 bec433416691fe0d390ca3e05d3d86a7.cloudfront.net (CloudFront)","x-amz-cf-pop":"DEL54-C4","x-amz-cf-id":"gXeZCpGdYWqyN9Af5tbkrksdYWO8L2pF8vBi7qpBswvcxgh2VljXrg=="},"status":400,"text":"{\"message\":\"invalid input: unable to parse base32 digest data 'txid': illegal base32 data at input byte 0\"}\n"}}

and the code is:

async makeTransaction() {
        try {
            const baseServer = "https://testnet-algorand.api.purestake.io/idx2";
            const port = "";

            const token = {
              "X-API-key": "Again my perfectly correct key",
            };

            const account = "account address";
        
            const algodClient = new algosdk.Algodv2(token, baseServer, port);
            let acc = await algodClient.accountInformation(account).do();
            let params = await algodClient.getTransactionParams().do();
            
            return params;
        } catch (e) {
            return e;
        }
    }

Please somebody help.

Hi!

Some minor changes are needed in your code:
old:
async makeTransaction() {
new:
async function makeTransaction() {

Reason: otherwise you get syntax error

old:
const baseServer = "https://testnet-algorand.api.purestake.io/idx2";
new:
const baseServer = "https://testnet-algorand.api.purestake.io/ps2";

Reason: you specified the index server as the base server

I hope this helps…
Good luck!

1 Like

Thanks so much it helped a lot :slightly_smiling_face: