Why Token URI cannot find the Token Id?

hello , I get this error after I minted a Token :
Value Error: execution reverted: ERC721Metadata: URI query for nonexistent token: ‘(‘ERC721Metadata: URI query for nonexistent token’,)’

and the command is :

def main():

    print("Working on " + network.show_active())

    advanced_collectible = getMultiDataTypeTemplate[len(getMultiDataTypeTemplate) - 1]

    number_of_NFT = advanced_collectible.TokenId()

    print(advanced_collectible.address)

   # print(advanced_collectible.tokenURI(TokenId))

    print(

        "The number of tokens you've deployed is: "

        + str(number_of_NFT)

         

    )

    for TokenId in range(number_of_NFT):

        breed = get_breed(advanced_collectible.TokenId())

        print(breed)

        print(advanced_collectible.tokenURI(TokenId))

        if not advanced_collectible.tokenURI(TokenId).startswith("https://"):

          print("Setting tokenURI of {}".format(TokenId))

you usually get this error when that token ids doesn’t exist, maybe you have to wait some time if you just minted that token id

okay when I run this :
def main():

  print("Working on " + network.show_active())

    advanced_collectible = getMultiDataTypeTemplate[len(getMultiDataTypeTemplate) - 1]

    number_of_NFT = advanced_collectible.TokenId()

    print(advanced_collectible.address)

   # print(advanced_collectible.tokenURI(TokenId))

    print(

        "The number of tokens you've deployed is: "

        + str(number_of_NFT)

I get this output :

The number of tokens you’ve deployed is: 1

so If it did not minted how it recognized I already minted a Token ? it would be my pleasure if you clarify this , thanks

you can see here how to post code on forum:

I changed the type , now is it okay to read ?

yes, it is better now, you have to know the exact token id that was minted, can you find it in a block explorer?

yes , take a look at these pictures please :

I don’t see the token id in those images

its the TokenID in the right that shows TokenID : 1

is it true ?

yes, that look like a token id

so where is the problem in your opinion ?
I used tokenURI(unint256 tokenId) in my contract instead of using _setTokenURI … do you think it’s the problem or not ?

try to print the TokenId here to see if if has the value that you expect

it shows 0 for print(TokenId)
but it show 1 for print(number_of_NFT) that is number_of_NFT = advanced_collectible.TokenId()

You are using somewhere this number?

could you clarify this please ? what do you mean by using this number ?
yes I called this function in another file , I mean this func : number_of_NFT = advanced_collectible.TokenId()

Where you get the error, what parameters are you using?

sorry I lost my conncetion .
when I run the command below I get the Error.
it can not recognize the TokenId it returns : URI query for nonexistent token

if not advanced_collectible.tokenURI(TokenId).startswith("https://"):

          print("Setting tokenURI of {}".format(TokenId))

[/quote]

Add some logging for that token id that is used as parameter. To see what is the value. Then see if it is the expected value or not.

OKay I’m not really experienced in using Logging , so could you please tell me how to define the logging for the specific value in the command below ? :

def main():

    print("Working on " + network.show_active())

    advanced_collectible = getMultiDataTypeTemplate[len(getMultiDataTypeTemplate) - 1]

    number_of_NFT = advanced_collectible.TokenId()

    #print(advanced_collectible.address)

   # print(advanced_collectible.tokenURI(TokenId))

    print(

        "The number of tokens you've deployed is: "

        + str(number_of_NFT)

         

    )

    for TokenId in range(number_of_NFT):

        breed = get_breed(advanced_collectible.TokenId())

        print(breed)

        print(TokenId)

        print(number_of_NFT)

        print(advanced_collectible.tokenURI(TokenId))

        if not advanced_collectible.tokenURI(TokenId).startswith("https://"):

          print("Setting tokenURI of {}".format(TokenId))

      set_tokenURI(TokenId, advanced_collectible,

             #            Status[breed])

The error specifically comes after this line :

print(advanced_collectible.tokenURI(TokenId))

        if not advanced_collectible.tokenURI(TokenId).startswith("https://"):

          print("Setting tokenURI of {}".format(TokenId))

Just use a print to print the value. That is what I wanted to say