You need to sign in to do that
Don't have an account?
NSK000
how to call an url from salesforce
Hi guys,
I'm having issues calling an url from salesforce.
Here is th code.
private final String clientId = 'xxxxxxxxx';
private final String clientSecret = 'xxxxxx';
String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret;
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setBody(reqbody);
request.setMethod('GET');
request.setEndpoint('http://xxxx/api/xx-xxx-xxxxxxx-api/v1.0/getEmplId?firstName=xxx&lastName=xxx&middleName=xx');
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());
}
I'm getting the following message - response|"System.HttpResponse[Status=Service Unavailable, StatusCode=503]".
I've added the site url in salesforce.
Please let me what I'm doing wrong?!
Appreciate your help!
Thanks,
NSK
I'm having issues calling an url from salesforce.
Here is th code.
private final String clientId = 'xxxxxxxxx';
private final String clientSecret = 'xxxxxx';
String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret;
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setBody(reqbody);
request.setMethod('GET');
request.setEndpoint('http://xxxx/api/xx-xxx-xxxxxxx-api/v1.0/getEmplId?firstName=xxx&lastName=xxx&middleName=xx');
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());
}
I'm getting the following message - response|"System.HttpResponse[Status=Service Unavailable, StatusCode=503]".
I've added the site url in salesforce.
Please let me what I'm doing wrong?!
Appreciate your help!
Thanks,
NSK
Check this - https://httpstatuses.com/503
The server where the API is hosted is having the issue.
--
Magulan Duraipandian
www.infallibletechie.com
All Answers
Check this - https://httpstatuses.com/503
The server where the API is hosted is having the issue.
--
Magulan Duraipandian
www.infallibletechie.com
Client id and client secret can be passed through request.setbody() ? My code above is correct ?
--
Magulan Duraipandian
www.infallibletechie.com