Are batch json-rpc requests not supported with near?

Viewed 214

When trying to batch json rpc requests like this:

[
    {
        "jsonrpc":"2.0",
        "id":"46500000",
        "method":"block",
        "params":{
            "block_id": 46500000
        }
    },
    {
        "jsonrpc":"2.0",
        "id":"46500001",
        "method":"block",
        "params":{
            "block_id": 46500001
        }
    }
]

The response given is this:

{
    "jsonrpc": "2.0",
    "error": {
        "name": "REQUEST_VALIDATION_ERROR",
        "cause": {
            "name": "PARSE_ERROR",
            "info": {
                "error_message": "JSON RPC Request format was expected"
            }
        },
        "code": -32700,
        "message": "Parse error",
        "data": "JSON RPC Request format was expected"
    },
    "id": null
}

This is quite confusing since the above request is a valid jsonrpc request according to the spec. Are batch requests not supported on near?

1 Answers

You are right, batch JSON RPC requests are not supported by nearcore JSON RPC implementation. Batch JSON RPC requests can become arbitrary heavy. It is preferred to leverage load balancer to get several requests resolved, so just make separate calls instead of batching them.

I wonder what is your use-case, though. Maybe you want to take a look into Indexer Framework

Related