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”:[{“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;
}
}