400 bad request

Hi guys,

The call to getNFTsFromContract() is giving me a 400 error (please see screenshot.)

This actually happens for quite a few functions but not for getNFTs(); it works.

Please help!

Hi, can you give more details? Like what parameters are you using? Some code example, server address in a selectable format.

			getNFTsOfUser = async () => {
				const options = {
					chain: "eth",
					address: ethAddress,
					token_address: "0x4581649af66bccaee81eebae3ddc0511fe4c5312" //
				};
				await Moralis.Web3API.account.getNFTsForContract(options).then(value => {
				//await Moralis.Web3.getNFTs(options).then(value => {
					nfts = value;
					console.log(nfts);
				}, reason => {
					console.error(reason);
				});
			}

I get that error in my first message when the call to getNFTsForContract() tries to execute in the code above.

Other calls to Moralis.Web3API functions work well? Trying to figure out if is a general api problem or something in particular with this function.

I’m your print screen it looks like you get an error for a different api function.

If it is a general api problem sometimes it can be solved by accessing https://admin.moralis.io/web3Api in order to generate an api key in case that it was not already generated previously

That did the trick! Thank you. I hadn’t yet created/copied my API key.

One more thing, this NFT https://etherscan.io/token/0xda9f43015749056182352e9dc6d3ee0b6293d80a doesn’t show up in the results of getNFTs() or getNFTsForContract(). It also doesn’t show up in the results of getTokenBalances(). It’s an old NFT from 2018. Any idea how I can interact with this contract using Moralis?

You can post this question as a separate forum post, it may be an NFT that it doesn’t use any standard and that is why it may not be recognized. You can interact with a smart contract if you know its address and its ABI or its code.

The 400 (Bad Request) status code indicates that the server cannot or will not process the request because the received syntax is invalid, nonsensical, or exceeds some limitation on what the server is willing to process. It means that the request itself has somehow incorrect or corrupted and the server couldn’t understand it. The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method . Therefore, it prevents the website from being properly displayed. The main thing to understand is that the 400 Bad Request error is a client-side error.

The cause of a 400 error can be a wrongly written URL or a URL that contains unrecognizable characters. Another cause of the error might be an invalid or expired cookie. Also, if you try to upload a file that’s too large. If the server is programmed with a file size limit, then you might encounter a 400 error.