• Ben Warner 54
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I have a package that contains apex code using a named credential to access an external REST service. The code works fine in the dev org, but once packaged and deployed to a test (subscriber) org I'm getting a System.CalloutException with the following message:
 
The callout couldn't access the endpoint. You might not have the required permissions, or the named credential "My_Named_Credential" might not exist.

The named credential is not included in the package as the endpoint configuration needs to be different for each org, however I've created the named credential in the test (subscriber) org, exactly as I have it in the dev org. The documentation on the use of named credentials in Apex code within packages suggests that this should work fine:

<excerpt>
If you package Apex code that specifies a named credential as a callout endpoint, also add the named credential to that package or otherwise make sure that the subscriber organization has a valid named credential with the same name.
</excerpt>

Ref: http://www.salesforce.com/us/developer/docs/packagingGuide/Content/packaging_component_behavior.htm

My Apex code:

            // Setup the REST call
            Http http = new Http();
            String endpointURL = 'callout:My_Named_Credential'; // Named Credential
    
            // Establish the request
            HttpRequest reqData = new HttpRequest();
            reqData.setTimeout(20000);
            reqData.setEndpoint(endpointURL);
            reqData.setMethod('POST');

            // Attempt the API callout
            HTTPResponse res = http.send(reqData);

Has anyone been able to successfully get this working? Are there any work-arounds I need to be aware of?

Thanks in advance,
BW.
 
I have a package that contains apex code using a named credential to access an external REST service. The code works fine in the dev org, but once packaged and deployed to a test (subscriber) org I'm getting a System.CalloutException with the following message:
 
The callout couldn't access the endpoint. You might not have the required permissions, or the named credential "My_Named_Credential" might not exist.

The named credential is not included in the package as the endpoint configuration needs to be different for each org, however I've created the named credential in the test (subscriber) org, exactly as I have it in the dev org. The documentation on the use of named credentials in Apex code within packages suggests that this should work fine:

<excerpt>
If you package Apex code that specifies a named credential as a callout endpoint, also add the named credential to that package or otherwise make sure that the subscriber organization has a valid named credential with the same name.
</excerpt>

Ref: http://www.salesforce.com/us/developer/docs/packagingGuide/Content/packaging_component_behavior.htm

My Apex code:

            // Setup the REST call
            Http http = new Http();
            String endpointURL = 'callout:My_Named_Credential'; // Named Credential
    
            // Establish the request
            HttpRequest reqData = new HttpRequest();
            reqData.setTimeout(20000);
            reqData.setEndpoint(endpointURL);
            reqData.setMethod('POST');

            // Attempt the API callout
            HTTPResponse res = http.send(reqData);

Has anyone been able to successfully get this working? Are there any work-arounds I need to be aware of?

Thanks in advance,
BW.