[solved] Quesiton About Get NFT metadata Api [ETH]

Hi,
im trying to call the Get NFT Metadata api and i decided to test it with
specifically 0x8a90cab2b38dba80c64b7734e58ee1db38b8992e contract and tokenINDEX 29

when i call it on the website everything is good, but as soon as i call it from my code - it gets a token from the correct contract but the index is like 7628 instead of 29 and im very confused as to why it gets the wrong token?

At first i thought maybe its because of this line " * Requests for contract addresses not yet indexed will automatically start the indexing process for that NFT collection" but truth be told im not sure i understand what this means ;/

Secondly, i had to make the api call into C# and its quite possible that I made a simple mistake but im not sure how to fix.
Let me know if anyone can help, i can share the code too if needed

maybe you can share more details about the code that you used?

public static async Task GetTokenMetaDataMoralis(string contractAddress, string tokenIndex)
{
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri($“https://deep-index.moralis.io/api/v2/nft/getNFTMetadata?chain=0x1&format=decimal&normalizeMetadata=true&mediaItems=false&address={contractAddress}&tokenId={tokenIndex}”),
Headers =
{
{ “X-API-Key”, “api key” },
{ “accept”, “application/json” }
},
};

    using (var response = await client.SendAsync(request))
    {
        try
        {
            do
            {
                response.EnsureSuccessStatusCode();

                if (response.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
                {
                    Console.WriteLine("Waiting for 1 min. Too many Requests.");
                    await Task.Delay(60000);    //wait 1 min
                }
            } while (response.StatusCode != System.Net.HttpStatusCode.OK);

            var body = await response.Content.ReadAsStringAsync();

            var jBody = JObject.Parse(body);

            return jBody.ToString();
        }
        catch
        {
            Console.WriteLine("Couldnt get the token from moralis");
            return null;
        }
    }
}

the response is OK, and it actually gets everything, but it just gets it for the wrong token

try to add some logging here to see if the parameters have the expected value

Token Index and Contract Address are correct there thats why i was banging my head as to whats happening

you can add more logging, like the complete requestUri to see how it looks like

1 Like

https://deep-index.moralis.io/api/v2/nft/getNFTMetadata?chain=0x1&format=decimal&normalizeMetadata=true&mediaItems=false&address=0x8a90cab2b38dba80c64b7734e58ee1db38b8992e&tokenId=29 the request thats being generated

but after getting an OK for the above request it just gives me a body with 7628 token index instead of the token index that was given to it i dont get it :rofl:

you may want to use this endpoint:

https://deep-index.moralis.io/api/v2/nft/0x8a90cab2b38dba80c64b7734e58ee1db38b8992e/29

It seems to return what you are expecting

1 Like

Yep, that works, thanks a lot :slight_smile:

1 Like