I am making a callout and getting the error
"System.CalloutException: The callout couldn't access the endpoint. You might not have the required permissions, or the named credential "XXX" might not exist."
When I inspect the log, it appears that the Named callout has all values as null. I don't understand why since we already set up the named credential in Salesforce.
I am attaching both the named credential and the error log.
HttpRequest reqData = new HttpRequest();
Http http = new Http();
String subscriptionApi = 'callout:xxx/https://xxx.com/api/v2/customers/' + custId + '/subscription_for_items' + params;
System.debug('Complete request ' + subscriptionApi);
String method = 'POST';
reqData.setHeader('Authorization', 'Username xxxxx');
reqData.setHeader('Content-Type', 'application/x-www-form-urlencoded');
reqData.setHeader('Connection','keep-alive');
reqData.setTimeout(25000);
reqData.setEndpoint(subscriptionApi);
reqData.setMethod(method);
HTTPResponse response = http.send(reqData);
System.debug('response ' + response);
return response;
Any ideas? Thanks
EDIT: After incorporating Keith's suggestion the values are now not null. I am now getting this
callout:xxx/
should replace thehttps://xxx.com/
as the named credential identifies the endpoint server. May not be the only problem though...JSON.serializePretty(response)
. And if you have any access to the service you are calling, look for errors at that side too.