[Unity / BUG] Moralis.Web3Api.Account.GetNFTsForContract

Moralis.Web3Api.Account.GetNFTsForContract stopped working after switching from 1 dapp (free account) to a paid one. The only change in the Unity app was Moralis credentials.

Android logcat:

  1. 2022.06.16 15:05:04.235 28505 28524 Error Unity Error: HTTP/1.1 400 Bad Request 2022.06.16 15:05:04.235 28505 28524 Error Unity {“code”:141,“error”:“Invalid function: “getNFTsForContract””} 2022.06.16 15:05:04.235 28505 28524 Error Unity MoralisUnity.Web3Api.d__7:MoveNext() 2022.06.16 15:05:04.235 28505 28524 Error Unity UnityEngine.AsyncOperation:InvokeCompletionEvent() 2022.06.16 15:05:04.235 28505 28524 Error Unity 2022.06.16 15:05:04.240 28505 28524 Error Unity Error calling GetNFTsForContract: {“code”:141,“error”:“Invalid function: “getNFTsForContract””}

Unity code:


public static async Task<NFTProfile[]> GetNftsByAddressForContract(string address, string contract)
    {
        try
        {
#if UNITY_WEBGL
                NftOwnerCollection noc =
                    await Moralis.Web3Api.Account.GetNFTsForContract(address.ToLower(),
                    contract,
                    ChainList.eth);
#else
            NftOwnerCollection noc =
                await Moralis.Web3Api.Account.GetNFTsForContract(address.ToLower(),
                contract,
                ChainList.eth); //org ChainList.mumbai --> did not yield correct results!
#endif
            PrintNftOwnerCollectionResult(noc.Result);

            NFTProfile[] nftProfiles = new NFTProfile[noc.Result.Count];

            if (noc.Result == null || noc.Result.Count == 0)
            {
                return null;
            }

            for (int i = 0; i < noc.Result.Count; i++)
            {
                nftProfiles[i] = NftOwnerToNFTProfile(noc.Result[i]);
            }

            return nftProfiles;
        }
        catch (Exception exp)
        {
            Debug.LogError(exp.Message);
        }

        return null;
    }

that that happen every time? did you try to restart the server? is the server working?

it works with the previous server?

Hi,
We managed to solve it by creating another dapp with different chainlist setup (modifying for the current one did nothing).
Best

1 Like