0.0.36 SDK -- Web3API.token.getTokenIdMetadata Not working

Iโ€™m having some issues with getTokenIdMetadata from the new SDK:

When attempting to use getTokenIdMetadata, my app errs out and I get a 400 in my web console:

POSThttps://.moralisweb3.com:2053/server/functions/getTokenIdMetadata
[HTTP/2 400 Bad Request 300ms]

As per the advice of CryptoKid in the Moralis discord, I restarted and upgraded my server to 0.251, but Iโ€™m still receiving a 400 when I attempt to call the getTokenIdMetadata. Here is a snippet of of the parameters, and code Iโ€™m using to call this function (token contract is a from an old test env) :

    const TOKEN_CONTRACT_ADDRESS = "0x4E653a188103B54072B538AFEBAb914CDEF43345";
    const options = { address: TOKEN_CONTRACT_ADDRESS, token_id: '19', chain: 'bsc testnet' };
    const tokenIdMetadata = await Moralis.Web3API.token.getTokenIdMetadata(options);

Hi @Spencer_devs,

Did you try updating the Moralis npm packages in your project as well? Let me know which version is stated in your package.json ?

Also, check out this post from another developer who solved some of his issues this way.

Hope this helps.

Happy BUIDLing! :slight_smile:

This works fine for me:

 TOKEN_CONTRACT_ADDRESS = "0x5fed3f1e64def0d7ec2497211f83eed8efda7d1a";
    options = { address: TOKEN_CONTRACT_ADDRESS, token_id: '9', chain: '0x4' };
    tokenIdMetadata = await Moralis.Web3API.token.getTokenIdMetadata(options);
=>
{token_address: "0x5fed3f1e64def0d7ec2497211f83eed8efda7d1a", token_id: "9", contract_type: "ERC721", token_uri: "https://ipfs.moralis.io:2053/ipfs/QmQqaKv4gP78PcRk3D3yfQBo535ZWNdeHw8rir84okYXJR", metadata: "{\"name\":\"Snare Drum 1\",\"description\":\"What a Snareโ€ฆrcent\":\"1%\",\"value\":\"Hard\",\"trait_type\":\"Vibe\"}]}", โ€ฆ}

But this generates an error:

 TOKEN_CONTRACT_ADDRESS = "0x4E653a188103B54072B538AFEBAb914CDEF43345";
    options = { address: TOKEN_CONTRACT_ADDRESS, token_id: '19', chain: 'bsc testnet' };
    tokenIdMetadata = await Moralis.Web3API.token.getTokenIdMetadata(options);

=>
moralis.js:22119 POST https://mtpbh2zhvqjd.moralis.io:2053/server/functions/getTokenIdMetadata 400
dispatch @ moralis.js:22119
ajax @ moralis.js:22126
(anonymous) @ moralis.js:22228
Promise.then (async)
request @ moralis.js:22222
run @ moralis.js:427
run @ moralis.js:353
wrappers.<computed>.<computed> @ moralis.js:5550
(anonymous) @ VM6148:3
moralis.js:24219 Uncaught Error: [object Object]
    at handleError (moralis.js:22250)
    at async <anonymous>:3:23

this returns not found:

curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/nft/0x4E653a188103B54072B538AFEBAb914CDEF43345/19?chain=0x61&format=decimal' \
  -H 'accept: application/json' \
  -H 'X-API-Key: API_KEY'

Update: Moralis devs made it work now:

    TOKEN_CONTRACT_ADDRESS = "0x4E653a188103B54072B538AFEBAb914CDEF43345";
    options = { address: TOKEN_CONTRACT_ADDRESS, token_id: '19', chain: 'bsc testnet' };
    tokenIdMetadata = await Moralis.Web3API.token.getTokenIdMetadata(options);

=>
{token_address: "0x4e653a188103b54072b538afebab914cdef43345", token_id: "19", contract_type: "ERC721", token_uri: "https://ipfs.moralis.io:2053/ipfs/QmbkmYePQs2z4cotXFw7JVExD1njBETDvb2vRfW3nqFZoy", metadata: null, โ€ฆ}```
2 Likes

Thanks Moralis Devs! Such a quick fix :partying_face:

2 Likes