I've created a managed package to deploy some custom fields etc. I need a post install script to run and notify my server than the salesforce instance has installed the package. Here is my post install script:

public class PackagedInstallScript implements InstallHandler {
    public void onInstall(InstallContext context) {
        String payload = getPayload(context);
    private String getPayload(InstallContext context) {
        String version;
        if (Test.isRunningTest())
            version = '1.0';
            version = System.requestVersion().major() + '.' + System.requestVersion().minor();
        JSONGenerator gen = JSON.createGenerator(true);
        gen.writeStringField('Action', 'INSTALL_PACKAGE');
        gen.writeStringField('InstanceUrl', URL.getSalesforceBaseUrl().toString());
        gen.writeStringField('version', version);
        return gen.getAsString();
    public static void sendNotification(String payload) {
        HttpRequest request = new HttpRequest();
        if (!Test.isRunningTest())
            (new Http()).send(request);

When I install the package on another salesforce instance, I expect to receive a notification in my external application, however I get nothing. I'm not sure where I can find the debug log for this script to see if it's thrown an error?

Also note I am referencing a named credential for the url for my external app which is part of the managed package. I wonder if my namespace prefix affects how I reference it?

What am I doing wrong?

1 Answer 1


Yes, you need to use the namespace (see this question, basically, callout:myNameSpace__myCalloutName).

  • OK so adding my namespace prefix to the callout as suggested worked. WITHOUT the namespace prefix I was getting an 'unauthorized endpoint' exception but I'm still able to do without remote site settings by using the namespace prefix. Thanks.
    – rosghub
    Commented Aug 9, 2020 at 0:49
  • @jefferson Ah, good to know. I'll amend. Glad I was able to help!
    – sfdcfox
    Commented Aug 9, 2020 at 1:26
  • @jefferson Just confirming. You are able to make a callout to an external endpoint with this? It is a bit concerning that the remote site setting isn't required. Commented Aug 9, 2020 at 19:31
  • Yes. If you remove the managed package from the situation, I'm able to reference/make callouts to named credentials without remote site settings. When distributing in a managed package, like I said the namespace prefix is required otherwise you get an unauthorized endpoint exception even though the callout:named_cred resolves to the endpoint correctly. Odd behavior but it is what it is.
    – rosghub
    Commented Aug 9, 2020 at 21:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .