You need to sign in to do that
Don't have an account?
Andre Baxter 7
Status=Forbidden, StatusCode=403] response when making an Apex callout
Hello community, I'm having an issue getting a positive response(200 code) when making a callout to SBA API. I use the same authentication headers and endpoint in Postman and the response is successful. However, currently that's not the case for me in Salesforce. Below is my callout method code. The JSON is in a separate method. I have tried to do the callout without the body and headers and still receive the same response code. Anyone ever run into this issue and resolved it? Thanks.
public static string makeCallout(string jsonstring) {
//call out logic here
ETranDetails__c etranDetails = ETranDetails__c.getOrgDefaults();
HttpResponse response;
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setHeader('Authorization', etranDetails.API_Key__c);
request.setHeader('Vendor-Key', etranDetails.Vendor_Key__c);
request.setHeader('Content-Type', 'application/json');
request.setEndpoint(etranDetails.Forgiveness_Endpoint__c);
request.setMethod('POST');
request.setTimeout(120000);
request.setBody(jsonstring);
response = http.send(request);
return null;
}
public static string makeCallout(string jsonstring) {
//call out logic here
ETranDetails__c etranDetails = ETranDetails__c.getOrgDefaults();
HttpResponse response;
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setHeader('Authorization', etranDetails.API_Key__c);
request.setHeader('Vendor-Key', etranDetails.Vendor_Key__c);
request.setHeader('Content-Type', 'application/json');
request.setEndpoint(etranDetails.Forgiveness_Endpoint__c);
request.setMethod('POST');
request.setTimeout(120000);
request.setBody(jsonstring);
response = http.send(request);
return null;
}
All Answers
Can you create a dummy endpoint from hookbin and use it in your callout. That way we can check if there are any issues with the headers
Anudeep
Hi Anudeep,
I created an endpoint in Hookbin, and used that endpoint in my code. It returned with a positive status code of 200. Hookbin didn't reveal any issues from what I saw. However, I do know that 403 stems from failure at authorization. I've double and triple checked my vendor and api key. They're identical to what I use in Post man, but so far, no successful responses in Salesforce when using the true endpoint.