HTTP response JSON contains another JSON string inside message (double-encoded?)

I’m calling a REST API using an HTTP Request activity and deserializing the response into a JSON object (outerJSON).

Normally, based on tutorials and examples online, once I deserialize the HTTP response once, the JSON is already usable and I can directly access fields.

However, in my case, the response behaves differently.

When I print/log responseContent.TextContent (the raw output of the HTTP Request), the actual data I need is not a JSON object, but a JSON string stored inside a property called message.

Example of the deserialized output (outerJSON):

{
“message”: “{ "id": "922991", "key": "NP-20857", "fields": { "summary": "Sample text" } }”,
“level”: “Information”,
“timeStamp”: “14:19:47”
}

So the message field itself contains escaped JSON as a string, instead of being a nested JSON object.

This is what confuses me, because most tutorials show that after:

  • HTTP Request
  • Deserialize JSON

…the result is already a usable JSON structure.
In my case, the actual Jira response seems double-encoded / encapsulated inside the message field.

What I’ve Tried

I extract the message field safely like this:

innerJSONString = If(
outerJSON IsNot Nothing AndAlso
outerJSON.ContainsKey(“message”) AndAlso
outerJSON(“message”) IsNot Nothing,
outerJSON(“message”).ToString,
“”
)

However:

  • innerJSONString looks empty or cannot be deserialized
  • Trying to deserialize it again sometimes throws
    Value cannot be null (Parameter 'JSON string')
    or
    Object reference not set to an instance of an object

Is this a case where the API response is double-encoded JSON? Do I need to deserialize the message field separately? What is the correct way to convert the message string into a usable JSON object so I can access fields like:

  • id
  • key
  • fields.summary

hi @Gerald_Varon,

Yes — this is double-encoded JSON.

Your API is returning a wrapper object, and the actual Jira payload is stored as a string inside the message property. So you need to deserialize twice.

Steps in UiPath:

  1. Deserialize the HTTP response:
  outerJSON = JsonConvert.DeserializeObject(Of JObject)(responseString)
  1. Extract the message value:
innerJSONString = outerJSON?("message")?.ToString
  1. If not null/empty, deserialize again:
If Not String.IsNullOrWhiteSpace(innerJSONString) Then
    innerJSON = JsonConvert.DeserializeObject(Of JObject)(innerJSONString)
End If

Then you can access:

innerJSON("id").ToString
innerJSON("key").ToString
innerJSON("fields")("summary").ToString

If innerJSONString is empty, log the raw responseString to confirm the actual structure returned by the API.

1 Like

Thank you for replying,

I’ve deserialized it once and then assigned it to a string variable. named “innerJSONString” with this Set value

If(outerJSON IsNot Nothing AndAlso outerJSON.Item(“message”) IsNot Nothing, outerJSON.Item(“message”).ToString(), Nothing)

but when I log message or message box, it’s empty. so when I deserialize it the 2nd time it errors.

the outerJSON is not empty because I print it out and this is the output (sample):

{
“message”: “{\r\n "expand": "SAMPLE",\r\n "id": "SAMPLE",\r\n "self": "SAMPLE",\r\n "key": "SAMPLE",\r\n "fields": {\r\n "summary": "SAMPLE"\r\n }\r\n}”,
“level”: “SAMPLE”,
“logType”: “SAMPLE”,
“timeStamp”: “SAMPLE”,
“fileName”: “SAMPLE”,
“jobId”: “SAMPLE”,
“robotName”: “SAMPLE”,
“machineId”: “SAMPLE”,
“userKey”: “SAMPLE”,
“processVersion”: “SAMPLE”,
“organizationUnitId”: “SAMPLE”,
“businessOperationId”: “SAMPLE”
}

I also tried this

outerJSON?(“message”)?.ToString

also returns nothing,

My Apologies, I’m a beginner in UiPath. I appreciate all the help I can get :smiley:

@Gerald_Varon

  • Ensure type = JObject
  • Access using outerJSON(“message”)
  • Log property names to verify the key
  • Log raw response to confirm structure

If it still returns Nothing, share: The type of outerJSON and also How you are deserializing (activity or code)

My Variables

Here’s what I have set up:

  • innerJSONString - String
  • innerJSON - JObject
  • issueJSON - JObject
  • outerJSON - JObject
  • responseContent - HttpResponseSummary

HTTP Request Response

The HTTP request returns something like this:

{
  "message": "{\"expand\":\"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations\",\"id\":\"720160\",\"self\":\"https://SAMPLE.atlassian.net/rest/api/3/issue/720160\",\"key\":\"NP-1234\",\"fields\":{\"summary\":\"TEST ONLY\"}}",
  "level": "Information",
  "logType": "User",
  "timeStamp": "12:34:56",
  "fileName": "Main",
  "jobId": "12340fee-1234-1234-8794-12341a0d1234",
  "robotName": "name@sample.com-attended",
  "machineId": 1234158,
  "userKey": "1234cb12-1234-4da6-b2cb-1b2f2572b1d0",
  "processVersion": "1.0.0",
  "organizationUnitId": 1234467,
  "businessOperationId": "12349b2ff454481123481112340a4fbe-36dbb21234e9442ca1234bd5fc111234"
}

Deserialize JSON

I deserialize the response content into a variable called outerJSON.

When I log it, it looks like this:

{
  "message": "{\r\n  \"expand\": \"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations\",\r\n  \"id\": \"123460\",\r\n  \"self\": \"https://SAMPLE.atlassian.net/rest/api/3/issue/123460\",\r\n  \"key\": \"NP-1234\",\r\n  \"fields\": {\r\n    \"summary\": \"TEST ONLY\"\r\n  }\r\n}",
  "level": "Information",
  "logType": "User",
  "timeStamp": "12:34:56",
  "fileName": "Main",
  "jobId": "12345ec7-1234-4e7c-86de-1234859a1234",
  "robotName": "name@sample.com-attended",
  "machineId": 1234158,
  "userKey": "1234cb12-4153-4da6-b2cb-12342572b1d0",
  "processVersion": "1.0.0",
  "organizationUnitId": 1234467,
  "businessOperationId": "c5e91234ca991234a5607c718d8b1242-126e3ea1234e4307837cea1831234e7f"
}

Extract the Inner Message

I want to get only the value of the message property into a variable innerJSONString.

Here’s what I’ve tried:

If(outerJSON IsNot Nothing AndAlso outerJSON.Item(“message”) IsNot Nothing, outerJSON.Item(“message”).ToString(), Nothing)

or the shorter version:

outerJSON?("message")?.ToString

Problem

Both methods give me an empty string. When I try to deserialize innerJSONString again, it returns null.

I feel like I’m missing a step or doing something wrong in handling this nested JSON string.

so when I deserialize it once again it’s null

Thank You!

I really appreciate anyone who can help me understand what I’m missing. Thanks in advance! :blush:

This looks like json for a UiPath log message. Perhaps you have clicked on a log message in the output panel and this has appeared?


So most likely there is not a double encoded json after all.

Uhm no, It did not show up like that

Based on that image one deserialization is enough. Did you already try and if so, did you get any error?

1 Like

Yes I’m receiving this error, the previous output I’ve sent was the outerJSON

I’ve tried this outerJSON?("message")?.ToString

it’s not allowing me to

Thank you, it would seems like I just have to use

outerJSON(“fields”)(“customfield_1234”).ToString

or

outerJSON(“fields”)(“summary”).ToString

I appreciate you all for commenting for a beginner like me.

Thanks everyone!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.