API Gateway: Add JSON element to JSON payload

book

Article ID: 206562

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

We have a JWT Payload like this:

{

  "sub": "domain.com",

  "aud": "Example Site",

  "iss": "https://domain123.com",

  "exp": 1610468532,

  "iat": 1610466732

}

 

We have a response.mainpart that holds the promoter id,

20210112 15:52:17.180 INFO                    -4           Response mainpart :{ "promoterId": "testPromoterId", "aud": "Example Site" }

 

How do we insert the promoterId element into payload message?

{

  "sub": "domain.com",

  "aud": "Example Site",

  "iss": "https://domain123.com",

  "exp": 1610468532,

  "iat": 1610466732,

  "promoterId": "testPromoterId"

}

Environment

API Gateway: 9.3

Resolution

One approach would be to use RegEx to remove the curly brackets and appends the variable to the payload. Attached is a sample policy.

NOTE: This is not intended to be a final solution. It is intended to be a guide towards a working solution.

Attachments

1610644429438__changePL.xml get_app