You need to sign in to do that
Don't have an account?
Michael M
Help with callout
Hello, I have been stuck on a callout I'm trying to make. When I did it from POSTMAN it worked successfully (i received a 200 response code), however it is not going through from Salesforce. Can anybody tell me if I'm either missing any steps or doing Named Credentials wrong? Please keep in mind that for this callout, I do not need user name or password, rather the external system vallidates the system based on certain information from the body of the callout itself.)
Here's my code, named credentials, and static resource:
Code:
public final Lead referral;
public String requestLabel;
public String result {get;set;}
public List<Object> seekData {get;set;}
public string reqbody;
StaticResource r =[Select Id,Body from StaticResource where Name='Seek_Callout_Body' limit 1];
reqBody=r.body.toString();
HttpRequest req = new HttpRequest();
// req.setHeader('Content-Length','0');
req.setHeader('Content-Type','text/xml');
req.setMethod('POST');
req.setBody(reqBody);
req.setEndpoint('callout:Seek');
req.setCompressed(true);
system.debug('FULL REQUEST: ' + req);
Http http = new Http();
HttpResponse response = http.send(req);
// Parse the JSON response
if (response.getStatusCode() != 201) {
System.debug('The status code returned was not expected: ' +
response.getStatusCode() + ' ' + response.getStatus());
} else {
System.debug(response.getBody());
}
Static resource is .txt file of this:
Here's my code, named credentials, and static resource:
Code:
public final Lead referral;
public String requestLabel;
public String result {get;set;}
public List<Object> seekData {get;set;}
public string reqbody;
StaticResource r =[Select Id,Body from StaticResource where Name='Seek_Callout_Body' limit 1];
reqBody=r.body.toString();
HttpRequest req = new HttpRequest();
// req.setHeader('Content-Length','0');
req.setHeader('Content-Type','text/xml');
req.setMethod('POST');
req.setBody(reqBody);
req.setEndpoint('callout:Seek');
req.setCompressed(true);
system.debug('FULL REQUEST: ' + req);
Http http = new Http();
HttpResponse response = http.send(req);
// Parse the JSON response
if (response.getStatusCode() != 201) {
System.debug('The status code returned was not expected: ' +
response.getStatusCode() + ' ' + response.getStatus());
} else {
System.debug(response.getBody());
}
Static resource is .txt file of this:
All Answers
When I system.debug(req.getbody()) Here is what I'm seeing:
Does it look like it's cutting off the static resource in the middle? the debug logs look like the body is stopping at "</requestcode>
Here is what the actual body is looking like (in case the screenshot in my question didn't show clearly):
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CheckEligibility
xmlns="http://outdash.com/EligibilityIncyranceWebService">
<returnCode>**</returnCode>
<returnData></returnData>
<requestCode>EO</requestCode>
<vendorCode>CCA</vendorCode>
<facilityProviderNpi>1982913109</facilityProviderNpi>
<patientFirstName>Medicare</patientFirstName>
<patientLastName></patientLastName>
<patientDateOfBirth></patientDateOfBirth>
<patientSex></patientSex>
<payerCode>00431</payerCode>
<policyNumber></policyNumber>
<dateOfServiceForEligibilityChecking></dateOfServiceForEligibilityChecking>
</CheckEligibility>
</soap:Body>
</soap:Envelope>
Can you use remote site to send the request instead of named credential? If you still get the same result, you may have to check with API service provider.