skip to Main Content

My Apache processor setup is HandleHttpRequest -> InvokeHTTP ->HandleHttpResponse.

I’m hitting an API from Postman which invokes another API and gets the JSON data and returns.

Now in between InvokeHTTP -> HandleHttpResponse, I’m trying to add another processor which modifies data before returning a response.

My JSON is from InvokeHTTP

{
  "id": 1,
  "menuTempId": 28,
  "conceptId": 252,
  "menuId": 1,
  "currency": "SAR",
  "language": "En",
  "updatedAt": 1695114353000,
  "countryId": "SA",
  "version": "v1"
}

I want to modify it to look like this:

{
  "id": 1,
  "currency": "SAR",
  "language": "En",
  "countryId": "SA",
  "version": "v1"
}

I want to remove a few keys from JSON data. I have tried using UpdateAttribute -> JoltTransformJSON, but it’s not working.

Can you help me understand from which processor and configuration I can achieve this scenario.

2

Answers


  1. this jolt definition should work for you:

    [
      {
        "operation": "shift",
        "spec": {
          "id":        "id",
          "currency":  "currency",
          "language":  "language",
          "countryId": "countryId",
          "version":   "version"
        }
      }
    ]
    
    Login or Signup to reply.
  2. Only adding a JoltTransformJSON processor along with the following specification

    [
      {
        "operation": "shift",
        "spec": {
          "id|currency|language|countryId|version": "&"
        }
      }
    ]
    

    is enough.

    Where the pipe operators are used similar to they’re(or double pipes are) used in some well-known programming languages as OR operators and the ampersand stands for replicating the values of those keys.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search