I'm having trouble getting a POST request to go trough using the Execute Anonymous window. The endpoint is exactly the same in my postman and it goes trough with no issues, but keeps returning a 400 when sent from Salesforce.
I HAVE added 'https://graph.facebook.com' to my Remote Site Settings
And here is the code on the Execute Anonymous..
HttpRequest req = new HttpRequest();
req.setMethod('POST');
//Seting HttpRequest Method
req.setHeader('content-type', 'application/json');
//Seting HttpRequest header properties
req.setHeader('Content-Length', '2000');
req.setEndpoint('https://graph.facebook.com/v15.0/xxxxxxxxx/messages?recipient={id:xxxxxxxxxxxx}&message={text:"HELLO, HOW ARE YOU"}&messaging_type=MESSAGE_TAG&tag=ACCOUNT_UPDATE&access_token=xxxxxxxxxxxxxxxxxx');
Http http = new Http();
try{
HTTPResponse res = http.send(req);
//Executing web service call
System.debug('STATUS:' + res.getStatus());
System.debug('STATUS_CODE:' + res.getStatusCode());
}
catch(System.CalloutException e){
//Exception handling goes here..
system.debug(e);
}
Which is returning:
Content-Type
. Finally back to the POST thing, try formatting the way it does it in this page: developers.facebook.com/docs/messenger-platform/…System.HttpRequest[Endpoint=https://graph.facebook.com/v15.0/106622318855859/messages?recipient={id:5420438071372198}&message={text:"random text here"}&messaging_type=MESSAGE_TAG&tag=ACCOUNT_UPDATE&access_token=EAAHU2qak6aMBAC2Hp8Pk4NsBp5FSui0fCkRysRm5rFIzmMj6ntVefhBddnrZBfsTHci5IdZBH9k3bDbnI64VOjyMbKrI**TRUNCATEDHERE**
so I ended up shortening the message to just 'hi' and it ended up posting....