Get Streamed Global Datasource Results by ID
/essbase/rest/v1/datasources/query/data/{streamId}
Returns results from a global-level Datasource associated with the specified stream id.
Request
-
streamId(required): string
Stream id.
Response
- application/json
- text/plain
- text/csv
200 Response
OK
Results fetched successfully.
400 Response
Bad Request
Failed to stream results.
500 Response
Internal Server Error.
Examples
The following example shows how to fetch streamed results from a global Datasource.
The Stream Datasource Results endpoint returns a link containing a stream id, which must be used by the Get Streamed Datasource Results by ID endpoint. As the first call generates a stream ID that is used by the second call, they need to be issued in same HTTP session. Because the REST API is stateless, you must store the information from the first call using a cookie. In this example, cookies are stored using the --cookie-jar
option.
This example uses cURL to access the REST API from a Windows shell script. The calling user's ID and password are variables whose values are set in properties.bat
.
As an alternative to these endpoints, you may use Get Streamed Datasource Results, which works in a single request and does not need to store cookies.
Script with cURL Commands
call properties.bat
curl --cookie-jar cookies.txt -X POST https://myserver.example.com:9001/essbase/rest/v1/datasources/query -H Accept:application/json -H Content-Type:application/json -d '{ "query": "select * from Orcl_DS", "delimiter" : ","}' -u %User%:%Password%
curl -b cookies.txt -X GET https://myserver.example.com:9001/essbase/rest/v1/datasources/query/data/120322937 -H Accept:application/json -H Content-Type:text/csv -u %User%:%Password%
Sample Response from First Call
The first call, Stream Datasource Results
, returns column headers from the Datasource named Orcl_DS, and includes a link with a stream ID to fetch Datasource results.
{
"columns" : [ {
"id" : 0,
"name" : "DIMENSION_PRODUCT"
}, {
"id" : 1,
"name" : "DIMENSION_MARKET"
}, {
"id" : 2,
"name" : "DIMENSION_YEAR"
}, {
"id" : 3,
"name" : "DIMENSION_SCENARIO"
}, {
"id" : 4,
"name" : "SALES"
}, {
"id" : 5,
"name" : "COGS"
}, {
"id" : 6,
"name" : "MARKETING"
}, {
"id" : 7,
"name" : "PAYROLL"
}, {
"id" : 8,
"name" : "MISC"
}, {
"id" : 9,
"name" : "INITIAL_INVENTORY"
}, {
"id" : 10,
"name" : "ADDITIONS"
} ],
"links" : [ {
"rel" : "data",
"href" : "https://myserver.example.com:9001/essbase/rest/v1/datasources/query/data/120322937",
"method" : "GET",
"type" : "text/csv"
} ]
}
Sample Response from Second Call
The second call, Get Streamed Datasource Results by ID, consumes the stream ID from the first call and returns results from the Datasource in text/CSV format. The following streamed results are truncated for length.
"100-20","Washington","Aug","Actual","317.0","133.0","120.0","29.0","1.0","","304.0"
"100-20","Washington","Aug","Budget","390.0","160.0","110.0","20.0","","","350.0"
"100-20","Utah","Aug","Actual","160.0","72.0","27.0","33.0","1.0","","153.0"
"100-20","Utah","Aug","Budget","200.0","90.0","20.0","30.0","","","170.0"
"100-20","Nevada","Aug","Actual","90.0","41.0","12.0","21.0","0.0","","86.0"
"100-20","Nevada","Aug","Budget","110.0","50.0","10.0","20.0","","","100.0"
"100-20","Texas","Aug","Actual","120.0","52.0","17.0","12.0","0.0","","114.0"
"100-20","Texas","Aug","Budget","150.0","60.0","10.0","10.0","","","130.0"
"100-20","Oklahoma","Aug","Actual","55.0","22.0","6.0","11.0","0.0","","52.0"
"100-20","Oklahoma","Aug","Budget","60.0","20.0","0.0","10.0","","","60.0"
"100-20","Louisiana","Aug","Actual","154.0","63.0","17.0","11.0","0.0","","147.0"
"100-20","Louisiana","Aug","Budget","190.0","70.0","10.0","10.0","","","170.0"
"100-10","Oklahoma","Aug","Actual","155.0","68.0","22.0","12.0","0.0","","147.0"
"100-10","Oklahoma","Aug","Budget","190.0","80.0","20.0","10.0","","","170.0"
"100-10","Louisiana","Aug","Actual","118.0","48.0","13.0","11.0","0.0","","113.0"
"100-10","Louisiana","Aug","Budget","140.0","60.0","10.0","10.0","","","130.0"
...