Hello everyone!
I am currently trying to learn Moralis and I have a problem: when performing the SearchNFTs function I get a HTTP Bad request error. While I can successfully retrieve user’s currency and the NFTs they bought given a specific contract, I cannot search for NFTs.
The code I use to perform the search is the one found here and is the following
using System;
using System.Collections.Generic;
using System.Linq;
using MoralisUnity;
using MoralisUnity.Platform.Objects;
using MoralisUnity.Web3Api.Models;
using UnityEngine;
using UnityEngine.InputSystem;
public class NftBrowserController : MonoBehaviour
{
public async void SearchNft(TMPro.TMP_InputField inputField)
{
Debug.Log("Searching for " + inputField.text);
try
{
NftMetadataCollection nfts = await Moralis.Web3Api.Token.SearchNFTs(inputField.text, ChainList.eth, filter: "global");
Debug.Log(nfts.ToJson());
}
catch (Exception e)
{
Debug.Log(e);
}
}
}
The error I get is the following.
MoralisUnity.Web3Api.Client.ApiException: Error calling SearchNFTs: {"code":141,"error":"Invalid number string: for variable"}
at MoralisUnity.Web3Api.CloudApi.TokenApi.SearchNFTs (System.String q, MoralisUnity.Web3Api.Models.ChainList chain, System.String format, System.String filter, System.Nullable`1[T] fromBlock, System.Nullable`1[T] toBlock, System.String fromDate, System.String toDate, System.String cursor, System.Nullable`1[T] limit) [0x0027e] in D:\Unity\Projects\MoralisProject\MoralisProject\Packages\io.moralis.web3-unity-sdk\Runtime\Web3Api\CloudApi\TokenApi.cs:499
at Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2[TStateMachine,T].GetResult (System.Int16 token) [0x00000] in D:\Unity\Projects\MoralisProject\MoralisProject\Packages\io.moralis.web3-unity-sdk\Runtime\External\UniTask\Runtime\CompilerServices\StateMachineRunner.cs:342
at NftBrowserController.SearchNft (TMPro.TMP_InputField inputField) [0x00074] in D:\Unity\Projects\MoralisProject\MoralisProject\Assets\_Scripts\NftRelated\NftBrowserController.cs:88
UnityEngine.Debug:Log (object)
NftBrowserController/<SearchNft>d__6:MoveNext () (at Assets/_Scripts/NftRelated/NftBrowserController.cs:94)
System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:Run ()
Cysharp.Threading.Tasks.AwaiterActions:Continuation (object) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTask.cs:21)
Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1<MoralisUnity.Web3Api.Models.NftMetadataCollection>:TrySetException (System.Exception) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTaskCompletionSource.cs:167)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2<MoralisUnity.Web3Api.CloudApi.TokenApi/<SearchNFTs>d__15, MoralisUnity.Web3Api.Models.NftMetadataCollection>:SetException (System.Exception) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:334)
MoralisUnity.Web3Api.CloudApi.TokenApi/<SearchNFTs>d__15:MoveNext () (at Packages/io.moralis.web3-unity-sdk/Runtime/Web3Api/CloudApi/TokenApi.cs:503)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2<MoralisUnity.Web3Api.CloudApi.TokenApi/<SearchNFTs>d__15, MoralisUnity.Web3Api.Models.NftMetadataCollection>:Run () (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:313)
Cysharp.Threading.Tasks.AwaiterActions:Continuation (object) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTask.cs:21)
Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1<System.Tuple`3<System.Net.HttpStatusCode, System.Collections.Generic.Dictionary`2<string, string>, string>>:TrySetResult (System.Tuple`3<System.Net.HttpStatusCode, System.Collections.Generic.Dictionary`2<string, string>, string>) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTaskCompletionSource.cs:139)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2<MoralisUnity.Web3Api.Client.ApiClient/<CallApi>d__12, System.Tuple`3<System.Net.HttpStatusCode, System.Collections.Generic.Dictionary`2<string, string>, string>>:SetResult (System.Tuple`3<System.Net.HttpStatusCode, System.Collections.Generic.Dictionary`2<string, string>, string>) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:328)
MoralisUnity.Web3Api.Client.ApiClient/<CallApi>d__12:MoveNext () (at Packages/io.moralis.web3-unity-sdk/Runtime/Web3Api/Client/ApiClient.cs:137)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2<MoralisUnity.Web3Api.Client.ApiClient/<CallApi>d__12, System.Tuple`3<System.Net.HttpStatusCode, System.Collections.Generic.Dictionary`2<string, string>, string>>:Run () (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:313)
Cysharp.Threading.Tasks.AwaiterActions:Continuation (object) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTask.cs:21)
Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1<System.Tuple`3<System.Net.HttpStatusCode, System.Collections.Generic.Dictionary`2<string, string>, string>>:TrySetResult (System.Tuple`3<System.Net.HttpStatusCode, System.Collections.Generic.Dictionary`2<string, string>, string>) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTaskCompletionSource.cs:139)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2<MoralisUnity.Web3Api.UniversalWebClient/<ExecuteAsync>d__7, System.Tuple`3<System.Net.HttpStatusCode, System.Collections.Generic.Dictionary`2<string, string>, string>>:SetResult (System.Tuple`3<System.Net.HttpStatusCode, System.Collections.Generic.Dictionary`2<string, string>, string>) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:328)
MoralisUnity.Web3Api.UniversalWebClient/<ExecuteAsync>d__7:MoveNext () (at Packages/io.moralis.web3-unity-sdk/Runtime/Web3Api/UniversalWebClient.cs:113)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2<MoralisUnity.Web3Api.UniversalWebClient/<ExecuteAsync>d__7, System.Tuple`3<System.Net.HttpStatusCode, System.Collections.Generic.Dictionary`2<string, string>, string>>:Run () (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:313)
Cysharp.Threading.Tasks.Internal.PooledDelegate`1<UnityEngine.AsyncOperation>:Run (UnityEngine.AsyncOperation) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/Internal/PooledDelegate.cs:46)
UnityEngine.AsyncOperation:InvokeCompletionEvent ()
Does anyone have a possible solution for this? Thanks in advance!