1

We are intent to use Marketing Cloud API using Apex Callout. Initially, I was trying to set up a Name Credential and Auth Provider for the Server-Server API Package on the MC side. But with my testing, I've got the from debug log: The NAMED_CREDENTIAL_REQUEST:

[.../rowset/, Method=GET, External Credential Type=EXTERNAL, HTTP Header Authorization=Not Set, Content-Type=null, Request Size bytes=-1, Retry on 401=True]

The NAMED_CREDENTIAL_RESPONSE_DETAIL:

{"documentation":"https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/error-handling.htm","errorcode":0,"message":"Not Authorized"}

Somehow the Auth.Provider doesn't set the 'Authorization' in the header of the named credential callout...

my Named Credential settings:

enter image description here

my Auth.Provider settings:

enter image description here

As you can see for the Named Credential I also checked 'Allow Merge Fields in HTTP Header', I also tried with req.setHeader('Authorization', '{!$Credential.OAuthToken}'); for the before the callout. It was still the same Authorization=Not Set.

Is there anything I did wrong? Thanks in advance.

I know there is a similar question here: Salesforce Marketing cloud rest API from Salesforce Cloud (apex) But there was no answer there, and our use cases are slightly different. I hope my question can provide more details for the experts like you to gain more insight to provide us with the solution.

1
  • Recommend sticking with Apex + NC to implementclient_credentials grant type (no auth provider). There are examples of this on here, do a search.
    – identigral
    Commented Mar 4, 2022 at 15:50

0

You must log in to answer this question.

Browse other questions tagged .