Skip to main content

Hi Folks,


I’m trying to connect to the monday.com api from Salesforce.


I get an initial OK - 200 when authenticating but then receive: {“errors”:r{“message”:“No query string was present”}],“account_id”:2027725} in the response body.


If I run the method


req.SetHeader('Content-Type', 'application/json');


I can’t even authenticate.


Any ideas? See code below.


public class mondayAPI{


public static httpResponse callout(){

String apiKey = 'my api key' here;

String query = '{ "query" : "{boards(ids: 813785147)}}" ';

//instantiate httpRequest

HttpRequest req = new HttpRequest();

//set http method and endoint for request instance

req.setMethod('POST');

req.setEndpoint('https://api.monday.com/v2');

//set body and header

req.setHeader('Authorization', apiKey);

req.setBody(query);

//instantiate the http

http h = new http();

//make the call out using the http.send() method

HttpResponse res = h.send(req);

Integer statusCode = res.getStatusCode();

String status = res.getStatus();

String body = res.getBody();



System.debug('Request Body: ' + req.getBody());

System.debug(statusCode);

System.debug(status);

System.debug(body);

return res;

}

}

Hey @SiriDeva - welcome to the community!


That error suggests to me that the call is being made to the monday API, and it is being verified against the account. However it cannot find a query string. Could we try have the query string as one whole uninterrupted line item?


String query = '{query : {boards(ids: 813785147)}} ';


-Daniel


Thanks for your response @dsilva.


I tried as you suggested and received the same error.


I’ve pasted the log below.


Appreciate your help!



I figured this out.


I had two errors.


The graphQL within my JSON request body was malformed.


correct is: String query = '{ "query" : "{boards(ids:413622857){id}}" }';


The content-type header needs to be set to json:


req.setHeader('Content-Type', 'application/json');