Skip to main content
May 28, 2025
Question

Suggestion on mapping Integration response

  • May 28, 2025
  • 9 replies
  • 0 views

I am getting the below response from Integration which is of type HttpResponse

[statusLine=HTTP/1.1 200 OK, statusCode=200, headers=[object Object], contentType=application/json; charset=utf-8, body={"jobId":"01091664F27E4771A9B92AEA0CC577ED"}].

I need to get the JobId value from the above and i ll have to map it to a process variable. To achieve this, i used an expression rule and used the below code:

if(
a!isNotNullOrEmpty(ri!integrationResponse),
a!fromJson(
index(ri!integrationResponse, "body", null)
),
{}
)

It resulted in "[jobId:01091664F27E4771A9B92AEA0CC577ED]" but i only need the JobId value from it. I tried various functions but nothing seems to be working. 

Can someone please suggest on how to proceed with this?

    9 replies

    harshas2775
    May 28, 2025

    Did you try this?

    if(
    a!isNotNullOrEmpty(ri!integrationResponse),
    a!fromJson(
    index(ri!integrationResponse, "body","jobId" null),
    ),
    {}
    )

    varuntejg243705
    May 28, 2025

    Hi [mention:3d9e2073c6ed490fab50c1895b8af5fe:e9ed411860ed4f2ba0265705b8793d05] ,

    I would suggest you to create a rule and use the integration in the following way:

    rule!ABC_FormatData(ri!response : ri!integrationResponse)

    a!localVariables(
      local!data: split(
        index(
          ri!response,
          "body",
          {}
        ),
        ":"
      ),
      local!jobId:index(local!data, 2, {}),
      left(local!jobId,count(char(code(local!jobId)))-1)
    )

    sarathkumr268295
    May 28, 2025

    Please try the below code

    index(index(ri!integrationResponse, "body", ""), "jobId", "")

    May 28, 2025

    i tried this it did not work

    davidj137213
    May 28, 2025

    You need to add one more index if you want to recover jobId value from the response.

    index(index(ri!integrationResponse, "body", null), "jobId", null)

    mikes0011
    Brainy
    May 28, 2025

    You need to step through this piece by piece to understand what's actually going on.

    Firstly we can see that the "body" you're getting back is a JSON string (I can see you're already trying to treat it as JSON but just reiterating here for clarity).

    So when "body" is populated, we will want to translate it back from JSON, which of course results in a dictionary:

    Now of course, as with all dictionaries/CDTs/maps, if we want only the property within the dictionary, we actually have to retrieve the value of that property (Even when the entire dictionary only holds one property).  For this, dot property would work, but if there's ever a chance it would be empty, it would be safer to use property().  (Note as always: property() and index() are the same function in the back-end; but my personal best practice is to use property() for properties, and index() for indices [i.e. positional within an array], for code cleanliness and readability).

    Side note: if you're passing the "body" value directly into a!fromJson(), then your null-safe returned value should be something that doesn't cause a!fromJson() to crash - I've found "[]" or "{}" work well.  It will error on you if you pass it null().

    May 28, 2025

    Good explanation.