Date: | 2008-1-15 |
---|---|
Web site: | http://groups.google.com/group/json-rpc |
Author: | Jeffrey Damick & JSON-RPC group - json-rpc -AT- googlegroups DOT com |
"JSON-RPC is a lightweight remote procedure call protocol. It's designed to be simple!" [JSON-RPC 1.0]
The goal of this document is to propose a JSON-RPC 1.2 extension to specify
For mailing list location: JSON-RPC Google Group
JSON-RPC over HTTP is an extension to the JSON-RPC 1.2 specification.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
Since JSON-RPC uses JSON, it shares the same type system as JSON (see http://www.json.org or RFC 4627). Whenever this document refers to any JSON type, the first letter is always capitalized: Object, Array, String, Number, True, False, Null.
Clients are the origin of Request objects. Servers are the origin of Response objects.
Requirements:
Regardless of whether a remote procedure call is made using HTTP GET or POST, the HTTP request message MUST specify the following headers:
Post body contains the Object request specified in JSON-RPC 1.2 section 2.4.
Response to a Post contains the Object response specified in JSON-RPC 1.2 section 2.5.
Responses with a null error will result in an HTTP 200 Status Code, while non-null error codes will be mapped to HTTP Status code as specified in the Errors section.
--> POST /ENDPOINT HTTP/1.1 Host: ... Content-Type: application/json-rpc Content-Length: ... {"method": "sum", "params": {"a":3, "b":4}, "id":0} <-- HTTP/1.1 200 OK ... Content-Type: application/json-rpc {"result": 7, "error": null, "id": 0} --> POST /ENDPOINT HTTP/1.1 Host: ... Content-Type: application/json-rpc Content-Length: ... {"method": "test", "params": [], "id": 0}
http://<end point>?method=<method name>¶ms=<encoded params>&id=1
Encoding Steps:
Pre-Encoded Params:
http://<end point>?method=sum¶ms={"a":3,"b":4}&id=2 http://<end point>?method=sum¶ms=[3,4]&id=1
Encoded Request:
http://<end point>?method=sum¶ms=eyJhIjozLCJiIjo0fQ%3D%3D&id=2 http://<end point>?method=sum¶ms=WzMsNF0%3D&id=1
For non-notification requests [3] including system procedures using POST or GET MUST indicate a success response using HTTP status code: 200.
However, for JSON-RPC 1.2 Notification requests, a success response MUST be an HTTP status code: 204.
HTTP Status | code | message |
500 | -32700 | Parse error. |
400 | -32600 | Invalid Request. |
404 | -32601 | Method not found. |
500 | -32602 | Invalid params. |
500 | -32603 | Internal error. |
500 | -32099..-32000 | Server error. |
For more details on error codes see table in JSON-RPC 1.2 section 2.5.1.
For more details on HTTP Status codes, refer to HTTP section 6.1.1.
[1] | Per JSON-RPC 1.2 specification |
[2] | http://classicasp.aspfaq.com/forms/what-is-the-limit-on-querystring/get/url-parameters.html |
[3] | JSON-RPC 1.2 section 2.4 |
Copyright (C) 2008 by JSON-RPC Working Group
This document and translations of it may be used to implement JSON-RPC over HTTP, it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way.
The limited permissions granted above are perpetual and will not be revoked.
This document and the information contained herein is provided "AS IS" and ALL WARRANTIES, EXPRESS OR IMPLIED are DISCLAIMED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.