enter image description hereI am connecting wave rest api using Ajax toolkit.I am getting error response like the below image if I pass the SAQL to the Wave REST API:enter image description here

enter image description here

<apex:page applyHtmlTag="true">
<script src="/soap/ajax/38.0/connection.js" type="text/javascript"></script>
<script type="text/javascript">
     function ctrlwave(){ 
         var envelope = "{query:\"q = load \"xxxxx\";\nq = group q by 'Name';\nq = foreach q generate 'Name' as 'Name', count() as 'count';\nq = order q by 'Name' asc;\nq = limit q 2;\"}";
                url : "https://key--xxxxx.salesforce.com/services/data/v38.0/wave/query",
                requestHeaders: {"Authorization":"Bearer "+'{!$API.Session_ID}',"Content-Type":"application/json",}, 
                requestData: envelope,
                method: "POST",
                onSuccess : function(response) {
              onFailure : function(response) {
              alert("Failed" + response)
<apex:form >
<div>Wave TOOL</div>
<apex:commandButton onclick="ctrlwave();" value="waveRet" id="theButton"/>

1 Answer 1


You have this payload:

{query: "..."}

You need to change it to:

{"query": "..."}

Which, since you have it wrapped in double quotes, is:

"{\"query\": \"...\"}"

I believe you also need to change load \"xxxxx\" to load 'xxxxx', but I cannot confirm.

  • Hi I have modified as you said .But Now also I am getting errors.First I tried by changing the payload error1 came check the question section for screenshot.Later I Modified the dataset name from \" to '.Where I getting error error2 refer the question for screenshot Commented Oct 13, 2016 at 1:23
  • First of all, you should paste in your error message text, instead of screenshots of the error. Second of all, the format of this forum makes continuous edits of a question not very useful. It would be better to ask a new question and link to this one for context if necessary.
    – Adrian Larson
    Commented Oct 13, 2016 at 2:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .