Macaulay2 » Documentation
Packages » JSONRPC » makeRequest
next | previous | forward | backward | up | index | toc

makeRequest -- construct a JSON-RPC request

Description

This method constructs a JSON-RPC request. The m parameter specifies the name of the method being called, while params contains the arguments for the method (if any). The optional ID parameter is used to correlate requests and responses. This method generates a JSON-encoded string representing the request, ready to be sent to the server. If no ID is provided, then the request is a notification and the server will return nothing.

i1 : makeRequest("foo", hashTable{"x" => 2, "y" => 3}, 1)

o1 = {"method": "foo", "id": 1, "jsonrpc": "2.0", "params": {"x": 2, "y": 3}}
i2 : makeRequest("baz", {4, 5, 6}, 2)

o2 = {"method": "baz", "id": 2, "jsonrpc": "2.0", "params": [4, 5, 6]}

When a list is given, its elements are expected to be sequences that can be passed to makeRequest. The result is an array containing a batch request.

i3 : makeRequest({
             ("foo", hashTable{"x" => 7, "y" => 8}, 3),
             ("bar", {9, 10, 11}, 4)})

o3 = [{"method": "foo", "id": 3, "jsonrpc": "2.0", "params": {"x": 7, "y":
     8}}, {"method": "bar", "id": 4, "jsonrpc": "2.0", "params": [9, 10,
     11]}]

Ways to use makeRequest:

  • makeRequest(List)
  • makeRequest(String)
  • makeRequest(String,HashTable)
  • makeRequest(String,HashTable,String)
  • makeRequest(String,HashTable,ZZ)
  • makeRequest(String,List)
  • makeRequest(String,List,String)
  • makeRequest(String,List,ZZ)
  • makeRequest(String,String)
  • makeRequest(String,ZZ)

For the programmer

The object makeRequest is a method function.


The source of this document is in JSONRPC.m2:451:0.