To get table resource data, execute request using the "rpc" API method (before executing the request determine user token).
The request contains resource parameters, and the X-Delta header is specified, on which the response depends:
NOTE. If resource parameters are not specified, default values are used. Default values for scalar parameters are set after resource import. An empty table with zero rows is a default value for table parameters.
If there is no X-Delta header, the response with full table or several resource tables is returned:
curl -v '<IP address or DNS name of server>/api/v1/rpc/<resource name>/' -H "Authorization: Bearer <user token>" -H "Content-Type: application/json" -d "{"<input parameter name>": <input parameter value>}"
The example in the JSON format:
Trying 0.0.0.0...
TCP_NODELAY set
Connected to <IP address or DNS name of server> (0.0.0.0) port 80 (#0)
> POST /api/v1/rpc/<resource name>/ HTTP/1.1
> Host: <IP address or DNS name of server>
> User-Agent: curl/7.61.1
> Accept: /
> Authorization: Bearer <user token>
> Content-Type: application/json
> Content-Length: 12
>
upload completely sent off: 12 out of 12 bytes
< HTTP/1.1 200 OK
< Server: nginx/1.9.11
< Date: <date>
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< ETag: "<ETag ID>"
< Expires: <date>
< Last-Modified: <date>
< Content-Version: <version number>
< Vary: Accept, Cookie, Accept-Encoding
< Allow: GET, POST, HEAD, OPTIONS
< X-Frame-Options: SAMEORIGIN
<
[{"name": "<table_name>", "data": [[1, 3, "Data"]]}]*
If data version is specified in value of the X-Delta header, the response contains delta between two versions:
curl -v '<IP address or DNS name of server>/api/v1/rpc/<resource name>/' -H "Authorization: Bearer <user token>" -d '{"<input parameter name>": "<input parameter name>"}' -H 'Content-Type: application/json' -H "X-Delta: v1-last"
The example in the JSON format:
< HTTP/ 1.1 200 OK
< Content-Version: "delta v1-v6"
< ...
< [{ "name" : "table_name1" , "insert_rows" : <table rows>, "delete_ids" : [ 3 , 7 , 10 ]}]
The Content-Type header in requests sets response format:
TableStream v0.2. If the header value is application/x-tablestream.
JSON. If the header value is application/json.
Request with specifying the ETag unique identifier.
Request to load cache on lost connection
To get data slice on a mobile device, use API requests with specifying parameters. Access to data of Foresight data source depends on user access permissions. User authentication is executed according to credentials of Foresight Analytics Platform.
The examples use resource names that are set on import in the Mobile Client Name box, for example, Dictionary, NSI_param, Cube, GrCube.
Examples of requests:
Sample data of dictionary with multiple element selection:
curl -v "http://localhost/api/v1/rpc/Dictionary/" -H "Authorization: Bearer token" -H "Content-Type: application/json" -H "X-Delta: auto" -d "{"param_LEN": "9" , "param_DIAM": "5" ,"param_PROD":"[[33],[34]]" , "group": null, "attributes": [[]]}"
Sample data of MDM dictionary with three parameters:
curl -v "http://localhost/api/v1/rpc/NSI_param/" -H "Authorization: Bearer token" -H "Content-Type: application/json" -H "X-Delta: auto" -d "{"param_LEN": "9" , "param_DIAM": "5" ,"param_PROD":"34" , "group": null, "attributes": [[]]}"
NOTE. Only one element can be selected in MDM dictionaries.
Sample all cube data:
curl -v "http://localhost/api/v1/rpc/Cube/" -H "Authorization: Bearer token" -H "Content-Type: application/json" -H "X-Delta: auto" -d '{ "dim_FACTS": null, "dim_OBJ195219": null, "group": null, "dim_OBJ195221": null, "dim_OBJ195223": null}'
Sample cube data with data filtering by dimension elements selection:
curl -v "http://localhost/api/v1/rpc/Cube/" -H "Authorization: Bearer token" -H "Content-Type: application/json" -H "X-Delta: auto" -d "{ "dim_FACTS ": null, "dim_OBJ195219 ": [[ "1 "],[ "2 "]], "group ": null, "dim_OBJ195221 ": null, "dim_OBJ195223 ": null}"
Sample cube data with data filtering by group of elements to one of the dimensions:
curl -v "http://locslhost/api/v1/rpc/GrCube/" -H "Authorization: Bearer token" -H "Content-Type: application/json" -H "X-Delta: auto" -d "{"dim_BALANCEINDICATORS_DICT":null, "dim_FACTSBUHBALANSE":null, "dim_REGISTRYSTRUCTURE_DICT":null, "dim_CALENDAR":null, "group": [["","","OBJ173485",""]]}"
See also: