I have issue with posting an API header to Bright Pattern out of Developer Console using a workspace. below is the Code and when I send it I get an error:
Execute Anonymous Error on line 6 column:19 Unexpected token '('
It looks like there is an Problem with the opening bracket after the request.setHeader
. However, it looks okay to me.
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://sprout.brightpattern.com/clientweb/api/v1/chats?tenantUrl=sprout.brightpattern.com×tamp=1538601898');
request.setMethod('POST');
// Set Header for the Authorization
request.setHeader('Content-Type', 'application/json;charset=UTF-8';
'Authorization: MOBILE-API-140-327-PLAIN'+ appId=9aeb0234a + clientId=WebChat);
// Set the body as a JSON object
request.setBody('{"LeadId":"00QM000000FL93tMAD"}');
// Parse the JSON response
HttpResponse response = http.send(request);
if (response.getStatusCode() != 201) {
System.debug('The status code returned was not expected: ' +
response.getStatusCode() + ' ' + response.getStatus());
} else {
System.debug(response.getBody());
}
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
appId=...
which seemed to be some sort of token. It's recommended not to post any credentials on public forum.