salesforcesalesforce-einstein

Getting error while calling Salesforce Einstein Analytics REST API SAQL query


I am trying to Fetch the dataset from Einstein Analytics through Analytics REST API SAQL Query Resource. I have followed the document given at https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_rest.meta/bi_dev_guide_rest/bi_resources_query.htm.

However, when I am calling the Salesforce Einstein Analytics through REST API from PostMan, I am getting below Response:

[
    {
        "errorCode": "118",
        "message": "Expected query or query name in body."
    }
]

The URL in the Postman POST request is

https://ap4.salesforce.com/services/data/v42.0/wave/query

My Request body contains:

{
"query":"q = load \"0Fb6F0000004eD4SAI/0Fc6F000001t5hWSAQ\";q = foreach q generate 'Account_Owner' as 'Account_Owner', 'Account_Type' as 'Account_Type', 'Amount' as 'Amount', 'Billing_State_Province' as 'Billing_State_Province', 'Close_Date_day_epoch' as 'Close_Date_day_epoch', 'Close_Date_sec_epoch' as 'Close_Date_sec_epoch', 'Column1' as 'Column1', 'Created_Date_day_epoch' as 'Created_Date_day_epoch', 'Opportunity_Name' as 'Opportunity_Name', 'Product_Name' as 'Product_Name';q = foreach q generate 'FirstName' as 'FirstName', count() as 'count';q = limit q 2000;"

}

Here while calling REST API I have made proper use of oAuth2.0 token.

Please let me know - what could be the problem in my Request, is the format of my request is correct.


Solution

  • I have got the solution to it, I had not set the content-type of my request as application/json.

    After setting it as a parameter in the header of the request in Postman, I am able to get the proper response.