2

I have created a custom journey builder activity type REST that can post to an external API successfully. However the external API requires a token for authentication that needs to be passed in the header of the request.

SFMC documentation here (https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/rest.htm) has a blank string for the headers and a url for the publish and save method headers. That makes absolutely no sense. Can somebody explain the format the headers should be in?

I am trying to pass "headers": [{"Authorization" : "Bearer theToken"}] via the json.config "execute" with no luck at all. I have tried the so many variations and no headers are passed to the API.

Any ideas?

6
  • What http response code are you getting?
    – Timothy
    Feb 4, 2021 at 17:22
  • I am receiving a 401 with message "Not Authorized" to all API endpoints that require an authorization header with a bearer token. I am receiving a 200 to all calls to REST API endpoints that do not require headers. When you look at the salesforce documentation here (developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/…) they are asking for a URL as the headers. So in what format should the headers [{"Authorization" : "Bearer theToken",{''Content-Type";"application/json'}}] be in within the config.json to work? Feb 5, 2021 at 7:36
  • Example snippet of headers within config.json -> arguments Feb 5, 2021 at 7:44
  • "arguments": { "executionMode": "{{Context.ExecutionMode}}", "definitionId": "{{Context.DefinitionId}}", "activityId": "{{Activity.Id}}", "contactKey": "{{Context.ContactKey}}", "execute": { "inArguments": [], "outArguments": [], "url": "", "verb": "POST", "body": "", "headers": [{"Authorization":"Bearer xxxx"},{"Content-Type":"application/json"}], "format": "json", "useJwt": false, "timeout": 10000 } Feb 5, 2021 at 7:44
  • What is the correct format for headers to pass through my Authorization header? Feb 5, 2021 at 7:45

1 Answer 1

3

Reached to the Marketing cloud team on this.

The custom headers are supported but for an access token, there is a bug that will be patched in the next release.

The release schedule (safe harbor) is below

R0 is 3/22 2021, R1 is 4/10 2021, and R2 is 4/17 2021

Once it is fixed, the below will work fine

arguments": {
    "execute": {
        "inArguments": [
            {
                "emailAddress": "{{InteractionDefaults.Email}}"
            },
            {
                "phoneNumber": "{{Contact.Default.PhoneNumber}}"
            }
        ],
        "outArguments": [
            {
                "foundSignupDate": ""
            }
        ],
        "url": "https://some-endpoint.com/execute",
        "headers": "{\"Authorization\":\"Bearer theToken\"}" 
    }
7
  • 1
    ​@Mohith Shrivastava thank you for the help. I ended up creating a micro-service that requires no headers to accept the call then relay it onto a specified REST service and attaching the required headers within my micro-service and returning the data back to the custom journey activity. This is working well. Feb 12, 2021 at 15:13
  • I think I picked up another bug with the custom activities on the outArguments. I successfully retrieve outArguments from my REST activity within the journey and can use decision splits on them however when I try and use outArgument within another custom REST activity in the format {{Interaction.REST-1.access_token}} then the journey cannot activate and throws an error. Can you confirm if I can use outArguments within another REST activity and within an Update Contact activity if my format is correct {{Interaction.REST-1.access_token}}? Feb 12, 2021 at 15:14
  • Good workaround for now! In April once it is fixed you can eat rid of the api call to attach the header! Feb 12, 2021 at 15:14
  • @Edwin Jeppe To help others can you post this as another query here? I can talk to marketing cloud engineers and see what they say Feb 12, 2021 at 15:33
  • 1
    I will post an additional query for the Update Contact activity issue Feb 12, 2021 at 15:41

You must log in to answer this question.

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