function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Daniel LiedkeDaniel Liedke 

Managed package external API call

Hello, I am facing issues calling external API HTTPS in managed packages. In unmanged package it is working fine but in managed package the code is aborting and there are no logs. The only error is in client side as general error. Even with Remote Site Settings correctly setup or using Named Credentials with permission set configured it is not working. How can I troubleshoot this? Thank you!
InzamamulInzamamul (Salesforce Developers) 
Hello Daniel,

I would request you to please please provide more information about your specific issue, such as the Apex code that you are using and the error that you are receiving so that I can help you more.

Thank You!

Heads up about the Forums shut down

User-added image
Important Update

We appreciate your participation in these Salesforce Discussion Forums! It’s active members like you that keep our amazing community going strong.

At this time, we want to give you a heads up that on December 4, 2023, the discussion forums will shut down and all relevant discussions will migrate to the Trailblazer Community digital platform. This move brings all conversations around Salesforce development together in one place and provides more opportunities for our broader community to connect and share. We will be removing outdated, obsolete, or spam content and migrating only relevant discussions to the Trailblazer Community digital platform.

Starting November 20, you can view discussions but not post new questions or responses. On December 2, you will no longer be able to access the discussion forums from the Salesforce Developers website.

Please take these steps before November 30, 2023, 11:59 p.m. PT to ensure your contributions follow you to the Trailblazer Community:
  1. If you’re not already a member of the Trailblazer Communitysign up for a Trailblazer account using the same login email address associated with your Developer Discussion Forums account. This is crucial.
  2. If you already have a Trailblazer account, and it’s using a different email address from the one you used for your Developer Discussion Forums account, we recommend that you log in to the Trailblazer Community and connect your forums email address to your Trailblazer account.
Once you’re in the Trailblazer Community, join the Migration Support Hub users group to help you navigate this transition.

We will keep you up to date throughout the transition, and we look forward to seeing you joining the developer discussions in the Trailblazer Community!

Sincerely,
The Forums Support Team
 
Daniel LiedkeDaniel Liedke
Hello, I finally could get it working. It was an weird problem retriving custom labels in managed package that was aborting the code.

Saving logs with SOQL queries saved the day. Managed package are very hard to troubleshoot without logs.
   public static void logMessageWithSOQL(String message) {
          
        // Sanitize the message to remove invalid characters
        String sanitizedMessage = sanitizeForSOQL(message);

        // Construct the SOQL query
        String queryString = 'SELECT Name FROM PermissionSet WHERE Name LIKE \'' + sanitizedMessage + '\' LIMIT 1';

        // Execute the query
        List<PermissionSet> results = Database.query(queryString);
    }
    
    private static String sanitizeForSOQL(String input) {
        
        if (String.isEmpty(input)) {
            return '';
        }
    
        // Replace new lines with space
    	String sanitized = input.replace('\n', ' ').replace('\r', ' ');
        
        // Replace single quotes (common SOQL injection risk)
        sanitized = input.replace('\'', '\\\'');
    
        // Remove non-alphanumeric characters except underscores, percent signs,
        // spaces, parentheses, and dots
        // Adjust the regex to include these additional characters
        sanitized = sanitized.replaceAll('[^\\w%()\\.\\s]', '');
    
        return sanitized;
    }

Example of logs for troubleshooting:
10:52:24.0 |SOQL_EXECUTE_BEGIN|SELECT Name FROM PermissionSet WHERE Name LIKE 'Before send() 
10:52:24.0 |SOQL_EXECUTE_BEGIN|SELECT Name FROM PermissionSet WHERE Name LIKE 'After send() 
10:52:24.0 |SOQL_EXECUTE_BEGIN|SELECT Name FROM PermissionSet WHERE Name LIKE 'Before getBody (MRA_Http_Util)' LIMIT 1
10:52:24.0 |SOQL_EXECUTE_BEGIN|SELECT Name FROM PermissionSet WHERE Name LIKE 'After getBody (MRA_Http_Util)' LIMIT 1

Thank you!


Daniel

 

Elia LeoElia Leo
in your input information might be some mistake, Please clearify that. You can also enjoy free tv shows, movies and more in pikashow apk download.https://scioly.org/forums/memberlist.php?mode=viewprofile&u=138367