I am trying to use this api to validate email addresses: https://developer.everest.validity.com/#bc0f96ba-bf72-45c3-82ed-36a2dc356e8a
I have it working fine in postman. I get a 200 response and a JSON body with it. Example response looks like the below:
{
"meta": {},
"results": {
"category": "email_domain_invalid",
"status": "invalid",
"name": "Domain Invalid",
"definition": "The email address is associated with a domain that doesn't exist. For example, evereeeeest.validity.com is not a real domain capable of sending and receiving email. So [email protected] is an invalid email since it pertains to a domain that does not exists.",
"reasons": [],
"risk": "very_high",
"recommendation": "suppress",
"address": "[email protected]",
"diagnostics": {
"role_address": false,
"disposable": false,
"typo": true,
"typo_suggestion": "gmail.com"
}
}
}
However, when trying to setup a basic apex REST callout, I again get a 200 response but it is returning an html table. I am very new to REST callouts, so figure I'm either missing something or there is a problem with the API.
Here is my apex callout code:
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.everest.validity.com/api/2.0/validation/address/[email protected]');
request.setMethod('GET');
request.setHeader('X-API-KEY', '[REDACTED]');
request.setHeader('Content-Type', 'application/json');
HttpResponse response = http.send(request);
System.debug(response.getBody());
When I check the debug it looks like this:
As you can the see, the html table has some semblance of correctness in that it starts with "meta" and "results" which are present in the correct JSON body response when using postman.
So it seems something about using Salesforce to do this callout is not working properly. Does anyone know if this is a salesforce issue or an issue with the API?
Thanks
Accept
in salesforce withapplication/json
?