Expand my Community achievements bar.

SOLVED

AJO Custom Action & Data Source - How to catch the Header values from Response ?

Avatar

Level 2

Hello,

 

In one of our clients' use case, we are working with an external system to which we need to make two API calls.

Call 1: Will give an API token. This API token is sent in response header (not in response body)

Call 2: Using the token from call 1, we have to call another API end point to save/update some data.

 

I know that in AJO custom action & data source, we can get the response body. But I am not sure how to get the response header.

 

Please share some ideas/thoughts how approach to this problem. 

 

Thank you and have a nice day ahead. 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee

You can use it on the following lines, specifying the type of authorization as "Custom Authorization"

 

This will incorporate the access token in the outbound api call via custom actions https://experienceleague.adobe.com/en/docs/journey-optimizer/using/configuration/configure-journeys/... 

dugganab_0-1721725261581.png

 

View solution in original post

18 Replies

Avatar

Employee

Could you share the requirement as to why response headers are needed ?

Avatar

Level 2

@dugganab thanks for your response.

 

The external system is designed to send API token in response header ONLY. 

So, we need a way to retrieve data from response header. 

Avatar

Correct answer by
Employee

You can use it on the following lines, specifying the type of authorization as "Custom Authorization"

 

This will incorporate the access token in the outbound api call via custom actions https://experienceleague.adobe.com/en/docs/journey-optimizer/using/configuration/configure-journeys/... 

dugganab_0-1721725261581.png

 

Avatar

Level 2

@dugganab , I am trying but it is not successful yet. 

So, to clarify, in the custom action > custom authorization > I have to put the entire request that get the API token (call 1) > then the token will be applied to call 2. So, I just need one custom action. Please confirm.

Avatar

Employee

Correct, it is just one custom action. What is the error you are running into ?

Avatar

Level 2

@dugganab , seems like Basic Authentication is not supported in authenticationType. 

The system we are trying to access is using Basic auth (user & password) for call 1 to get the token. 

Hence, the authentication is not getting successful.

 

Avatar

Employee

If it is basic authentication, you can switch the type to Basic.

 

dugganab_0-1721756450372.png

 

Avatar

Level 2

@dugganab , in that case, how to accommodate two calls in same action & retrieve the response header?

Avatar

Employee

If the end point you are trying to hit supports basic authentication, you don't need custom authorization. 

dugganab_0-1721756915207.png

 

Avatar

Level 2

@dugganab , Yes, it's OOTB.

But the point is I have to get the security token from call 1- response header. 

Then that security token needs to be applied when calling the main api (call 2)

 

Avatar

Employee

In the screenshot shared earlier, all of this happens in a single custom action & header ( -H "Authorization: Basic <base64 enconded username:password>") gets appended automatically when the custom action is invoked.

Avatar

Community Advisor

@Joydeep 

Just adding a little more info to @dugganab ’s suggestion

 

Call 2 should work with username/password as header parameters, not only with an API key (API Key is generated based on username and password). Please talk with the external system team to confirm that Call 2 works with username/password as header parameters. If confirmed by the external system team, proceed with basic authentication in AJO so that the username/password will be automatically added as header parameters to the Call 2 endpoint.

 

Call 2 - API key as header parameter https://abc.my.workfront.com/attask/api/v17.0/project/search?apiKey=xyz46v12vrz9snfkltyfeyefe0b0gx5h...

Call 2 - username/password as header parameter https://abc.my.workfront.com/attask/api/v17.0/project/search?username=anuhya.y@abc.com&password=hsgd...

 

 

Avatar

Level 2

@Anuhya-Y , @dugganab 

Thank you for offering your help so far.

API & Authorization:

  • Call 1 - Has Basic auth
  • Call 2 - Has Basic auth (same as Call 1) + API token received in Call 1 response header.
  • Call 1 & Call 2 end points are not same

Avatar

Community Advisor

@Joydeep Just add call2 endpoint url and username/password in the authentication. 

AnuhyaY_0-1721813765433.png

 

Avatar

Level 2

@Anuhya-Y , in that case, I am not getting the API token from call 1 which is required to authenticate call 2.

Avatar

Community Advisor

@Joydeep  Do NOT depend on Call1 to generate the API key. Instead, for Call2, just add the username and password details, which will internally create an API key. Could you please validate the Call2 response in Postman by passing the username and password as header parameters instead of the API key? Also, may I know the name of the external system?

Avatar

Community Advisor

@Joydeep 

Could you let me know if you're using custom authentication to generate token? If yes, the token generated from call 1 will pass as a request header parameter for call 2.

 

Check out these links https://medium.com/@anuhyareddy.y/ajo-jo-sending-email-delivery-via-3rd-party-marketing-automation-t...

https://experienceleague.adobe.com/en/docs/journey-optimizer/using/configuration/configure-journeys/...

Avatar

Level 2

@Anuhya-Y , thank you for your response.

 

Let me check.