When using Ankr's Advanced API or AAPI, you may sometimes bump into some errors.

These errors may be caused by actions on your side as well as service errors on Ankr's.

To learn how to fix the problem, you need a better understanding of AAPI.

📘

FYI

AAPI is not a RESTful service, it conforms to the JSON-RPC 2.0 spec. So the status code in response is always going to be 200 OK, regardless of the actual response. The error will return in the JSON body.

Request structure

First, understand the request better.

A request to AAPI has the following structure:

{ 
  "jsonrpc": "<jsonrpc_version>",
  "method": "<aapi_method_name>",
  "params": {
    "required_param_0": "<value>",
    "required_param_n": "<value>",  
    "optional_param_0": "<value>",
    "optional_param_n": "<value>",  
    },
   "id": <request_id>,  
}  

In this structure, fields jsonrpc, method, id, and params are main body fields required in each request.

The object params contains required and optional request parameters.

Here is a live request example:

{ 
  "jsonrpc": "2.0",
  "method": "ankr_getBlocks",
	"params": {
        "blockchain": "eth",
        "fromBlock": 14500001,
        "toBlock": 14500001,
        "decodeLogs": false,
        "decodeTxData": true,
        "includeLogs": true,
        "includeTxs": true,
        "descOrder": true
    },
    "id": "1",
}  

Request validation process

When you send a request, AAPI validates it in the following sequence:

  1. JSON syntax.
  2. Request body (id, method, jsonrpc).
  3. Parameters.

The validation process stops at the step that contains error(s), not going any further, and throws an error which is returned to you in the response.

Errors and error codes

Here are the errors thrown by AAPI and returned to you in the response if something goes wrong.

ErrRPCParse

Code: 32700
Message: "Parse error"

Problem: Your JSON breaks the JSON syntax convention. For example, a " is missing or you misspelled a property, or accidentally stoke the keyboard and added a symbol outside of the quotes.

Solution: Fix the JSON syntax of your request.

ErrRPCInvalidRequest

Code: 32600
Message: "Invalid request"

Problem: You missed or misspelled one of the main request fields: jsonrpc, method, id, and params.

Solution: Add the missing param or fix the spelling.

ErrRPCMethodNotFound

Code: 32601
Message: "Method not found"

Problem: You missed or misspelled the method name in the value of the method field.

Solution: Add the method name or fix its spelling. Refer to the AAPI docs you're reading now to check the name.

ErrRPCInvalidParams

Code: 32602
Message: "Invalid parameters"

Problem: You missed or misspelled one of the parameters in the params objectthe method name in the value of the method field.

Solution: Add the missing required params or fix their names or value format. Refer to the AAPI docs you're reading now to check the params. Here's how to find them.

ErrRPCInternal

Code: 32603
Message: "Internal error"

Problem: AAPI is out of service of needs maintenance.

Solution: The problem is on our side, and we're probably already fixing it. It's also a good idea to visit https://www.ankr.com/advanced-api/, click Feedback, and tell us about the problem you're experiencing. You may be the person to see the outage in its first minutes, even before we react, and a timely notice is always appreciated.