Unity Failed To Get NFTs After Self Hosting

Hello, I have followed all of the Troubleshooting with fixing all of the issues related to setup and authenticating with Moralis in Unity using a self hosted server. After succeeded in the above, now I can’t continue to retrieve NFTs as it used to be with the old server approach. How to get NFTs with the self hosted server? It should be the same with your Unity SDK, or else why didn’t you update it? Thank you

what happens, what doesn’t work?

you can create a cloud function and call it as an alternative

Getting NFTs is what doesn’t work. This function that used to work on the non-self hosted server: ‘NftOwnerCollection noc =
await Moralis.GetClient().Web3Api.Account.GetNFTsForContract(playerAddress.ToLower(),tokenAddress,
_deployedChain);’
is not retrieving anything and the function is falling back to the catch error area with object null

there is a new function now for that getNFTs by wallet, I don’t know the name for unity, is this one

Thank you, but this does not work for Unity. This is related to the back-end side. I am using Moralis’s Latest Unity SDK and this is the function that gets the NFTs and it is not working with the self hosted server that was created using Moralis’s Documentations and Videos.

there has to be another function with a similar name, in the past there were 2 functions with the same functionality and we deprecated one of them

This is the exact error after calling this function:
{“code”:141,“error”:"[C0005] Request contains unknown parameter: tokenAddress. This operation supports the following parameters: address, chain, format, limit, tokenAddresses, cursor, normalizeMetadata, disableTotal"}

try to use tokenAddresses instead of tokenAddress

And how is that possible? Moralis SDK is using tokenAddress value as url path in the API, How would I inject an array of addresses in it?

try with a single element initially, without an array, it should also work

So I only rename the token_address key in the body to token_addresses? is that what you are implying?

yes, try like that initially to see if it works

As expected, this doesn’t work.
In the newest documentation, it is stating that we should give one tokenAddress, which was the case since forever, but now suddenly it is not working! I don’t mind changing, but at least update documentation and/or SDK!
The error is as follows now, nothing changed since last error:
{“code”:141,“error”:"_a.map is not a function"}

Here is the Body sent by Moralis SDK to the GetTokenByContract Function:
{“address”:“0xc123123123123123123123123123”,“token_address”:“0xac123123123123123123123123123”,“cursor”:"",“chain”:“0x89”}"
And here is the Response:
{“code”:141,“error”:"[C0005] Request contains unknown parameter: tokenAddress. This operation supports the following parameters: address, chain, format, limit, tokenAddresses, cursor, normalizeMetadata, disableTotal"}

What is the error when you use tokenAddresses?

Here is the Result:
Body: “{“address”:“123123123123123”,“token_addresses”:“0x123123123123123123”,“cursor”:”",“chain”:“0x89”}"
Response
{“code”:141,“error”:"_a.map is not a function"}

Try to send and array then, with [0x12455]

This worked, but it required manipulating the Code of the SDK. This should be updated in the SDK to send the following in the body:
{“address”:“0xc08c9c87b3a01f4e37cb1159c66e35ad58980715”,“tokenAddresses”:[“0xac14d20ec4b3f1a8cb91b9ebecdc0133e89e42a4”],“cursor”:"",“chain”:“0x89”}
It should replace “token_address” param with “tokenAddresses” to follow the new Back-End requirement and replace the string value with an array of strings.

Thank You for your prompt responses on this thread!

1 Like

Hello @bassel.l can I ask how you manage to make it work? I tried to do it myself with your discussions above, but I’m still having errors