apex-recipes icon indicating copy to clipboard operation
apex-recipes copied to clipboard

Connect rest api in Apex does not automatically enabled named credentials when created

Open dewuyi opened this issue 1 year ago • 2 comments

Summary

When creating a Named Credential using the Salesforce Connect API via Apex, the "Enabled for Callouts" setting is not automatically toggled on. However, when the same Named Credential is created via Postman using the same Connect API, the "Enabled for Callouts" setting is automatically toggled on.

Salesforce Org Type

Sandbox

Steps To Reproduce

Configuration: Write an Apex class to create a Named Credential using the Connect API. Set up the Named Credential with the required details, including URL, External Credentials, and Callout Options. Deploy the Apex code to the Scratch Org. Run: Execute the Apex code to create the Named Credential.

Current Behavior

The Named Credential is created successfully, but the "Enabled for Callouts" toggle is not automatically enabled, requiring manual intervention to enable it. This behavior is inconsistent with creating Named Credentials via Postman using the same Connect API, where the toggle is automatically enabled.

Expected Behavior

The "Enabled for Callouts" setting should be automatically toggled on when the Named Credential is created using the Connect API via Apex, just as it is when created via Postman.

Relevant Log Output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

dewuyi avatar Aug 19 '24 19:08 dewuyi