Citizens, hello everyone!)

Can anyone explain to me the requirements for submitting a JSON-RPC request? That is, there is a server on some machine, and you need to send a request to json-rpc 2.0. But I do not understand what I have to consider when transferring. The length of the request, the number of bytes, I do not even know?

There is a code in C # that works correctly, but to write it in java is not enough understanding how the request works.

    2 answers 2

    The JSON-RPC specification is quite simple; in it you can find sample requests. If the JSON-RPC server runs on top of HTTP (the specification does not specify the type of transport, it can be used just TCP), then you usually need to send a POST request with the body containing the JSON type:

    { "jsonrpc": "2.0", "method": "имя_вызываемого_метода", "params": параметры_передаваемые_в_метод, "id": идентификатор_запроса } 

      Even on the wiki you can find examples .
      If they are not enough, then you can see the specification , as comrade @kmv advised, or look at the Habr .

      If simple, then traditionally (though not necessarily) JSON-RPC is used to provide web services, that is, via HTTP.
      A web service is accessed by an HTTP request using the POST method; there are some limitations , which are mainly determined by the implementation environment (that is, the server part).
      That is, JSON (string) is sent to the access point (usually it is one) according to the specification , and a response from the server is expected.

       >> { "jsonrpc": "2.0", "method": "web_function", "params": { "var1": 4, "var2": 42 } } << { "jsonrpc": "2.0", "result": 46, "id": null } >> { "jsonrpc": "2.0", "method": "web_function", "params": [ 'a', 'b' ], "id": 1 } << { "jsonrpc": "2.0", "result": 'ba', "id": 1 } >> { "jsonrpc": "2.0", "method": "web_function_2", "params": [ 'c', 1 ], "id": 2 } << { "jsonrpc": "2.0", "error": { "code": -32601, "message": "Method not found." }, "id": "2" } 

      Nevertheless, no one prohibits the use of WS as a transport in their web applications.
      For other applications, the choice of transport is even greater, and the restrictions are imposed only by the server and the specific implementation.