'XQuery get data with response Microstrategy

I've script for this. When i runned report, i can take the returns. Token, Auth Type,Expire Time and scope. With Microstrategy and XQuery language, i want to get data from other url with using this results.

Here is my post method:

import module namespace json = 'http://www.zorba-xquery.com/modules/json';
declare copy-namespaces no-preserve, no-inherit;
declare namespace mstr-rest = 'http://www.microstrategy.com/xquery/rest-functions';
declare function mstr-rest:post($uriResponse,$payloadResponse,$header) external;

let $header := ("Content-Type:application/x-www-form-urlencoded")

let $uriResponse := ('https://apiwg/token')
let $payloadResponse := ('grant_type=&username=&password=&client_id=-&client_secret=;scope=')
let $jsonresult := mstr-rest:post($uriResponse,$payloadResponse,$header)
let $response := json:parse($jsonresult)

this returns;Token, Auth Type,Expire Time and scope.

Next stage, how can i get data with this token? Like that;


Adress: https://apigw/search=example
Method: GET
Authorization: Bearer 688b9878-177a-4100-b027-8f302319bfda

Response: I need that.



Solution 1:[1]

Please check this community post.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fsbelinda