Not able to extract values from http request output variab;e

I have an api which returns me following response

“{"compositeResponse":[{"body":{"totalSize":1,"done":true,"records":[{"attributes":{"type":"Order__c","url":"/services/data/v59.0/sobjects/Order__c/a0T1e000001ZVbyEAG"},"Id":"a0T1e000001ZVbyEAG","Name":"OC-1066","OwnerId":"0055j000002IMmBAAW"}]},"httpHeaders":{},"httpStatusCode":200,"referenceId":"orders"},{"body":null,"httpHeaders":{},"httpStatusCode":204,"referenceId":"orderRecord"},{"body":{"id":"0681e000001njkyAAA","success":true,"errors":},"httpHeaders":{"Location":"/services/data/v49.0/sobjects/ContentVersion/0681e000001njkyAAA"},"httpStatusCode":201,"referenceId":"contentVersion"},{"body":{"attributes":{"type":"ContentVersion","url":"/services/data/v49.0/sobjects/ContentVersion/0681e000001njkyAAA"},"Id":"0681e000001njkyAAA","ContentDocumentId":"0691e000001nhggAAA","IsLatest":true,"ContentUrl":null,"ContentBodyId":"05T1e0000066Of9EAE","VersionNumber":"1","Title":"23000012","Description":null,"ReasonForChange":null,"SharingOption":"A","SharingPrivacy":"N","PathOnClient":"23000012","RatingCount":0,"IsDeleted":false,"ContentModifiedDate":"2024-03-22T10:17:09.000+0000","ContentModifiedById":"0051e000005FBqYAAW","PositiveRatingCount":0,"NegativeRatingCount":0,"FeaturedContentBoost":null,"FeaturedContentDate":null,"CurrencyIsoCode":"INR","OwnerId":"0051e000005FBqYAAW","CreatedById":"0051e000005FBqYAAW","CreatedDate":"2024-03-22T10:17:09.000+0000","LastModifiedById":"0051e000005FBqYAAW","LastModifiedDate":"2024-03-22T10:17:09.000+0000","SystemModstamp":"2024-03-22T10:17:09.000+0000","TagCsv":null,"FileType":"UNKNOWN","PublishStatus":"R","VersionData":"/services/data/v49.0/sobjects/ContentVersion/0681e000001njkyAAA/VersionData","ContentSize":45594,"FileExtension":null,"FirstPublishLocationId":"0051e000005FBqYAAW","Origin":"C","NetworkId":null,"ContentLocation":"S","TextPreview":null,"ExternalDocumentInfo1":null,"ExternalDocumentInfo2":null,"Checksum":"5527dc5588e4ccb156e9bc55bbaa8468","IsMajorVersion":true,"IsAssetEnabled":false},"httpHeaders":{"Last-Modified":"Fri, 22 Mar 2024 10:17:09 GMT"},"httpStatusCode":200,"referenceId":"contentVersionRecord"},{"body":{"id":"06A1e000003AjlXEAS","success":true,"errors":},"httpHeaders":{"Location":"/services/data/v49.0/sobjects/ContentDocumentLink/06A1e000003AjlXEAS"},"httpStatusCode":201,"referenceId":"refCDL"}]}”

I have tried using deserialize json activity but i am not able to extract values from it.
After deserialize i am getting jobject variable value as

{
JProperty(1)
{
JArray(5)
{
JObject(4)
{
JProperty(1)
{
JObject(3)
{
JProperty(1)
{
[1]
},
JProperty(1)
{
[True]
},
JProperty(1)
{
JArray(1)
{
JObject(4)
{
JProperty(1)
{
JObject(2)
{
JProperty(1)
{
[Order__c]
},
JProperty(1)
{
[/services/data/v59.0/sobjects/Order__c/a0T1e000001ZVbyEAG]
}
}
},
JProperty(1)
{
[a0T1e000001ZVbyEAG]
},
JProperty(1)
{
[OC-1066]
},
JProperty(1)
{
[0055j000002IMmBAAW]
}
}
}
}
}
},
JProperty(1)
{
JObject(0)
{

      }
    },
    JProperty(1) 
    {
      [200] 
    },
    JProperty(1) 
    {
      [orders] 
    }
  },
  JObject(4) 
  {
    JProperty(1) 
    {
      [] 
    },
    JProperty(1) 
    {
      JObject(0) 
      {
        
      }
    },
    JProperty(1) 
    {
      [204] 
    },
    JProperty(1) 
    {
      [orderRecord] 
    }
  },
  JObject(4) 
  {
    JProperty(1) 
    {
      JObject(3) 
      {
        JProperty(1) 
        {
          [0681e000001njiyAAA] 
        },
        JProperty(1) 
        {
          [True] 
        },
        JProperty(1) 
        {
          JArray(0) 
          {
            
          }
        }
      }
    },
    JProperty(1) 
    {
      JObject(1) 
      {
        JProperty(1) 
        {
          [/services/data/v49.0/sobjects/ContentVersion/0681e000001njiyAAA] 
        }
      }
    },
    JProperty(1) 
    {
      [201] 
    },
    JProperty(1) 
    {
      [contentVersion] 
    }
  },
  JObject(4) 
  {
    JProperty(1) 
    {
      JObject(44) 
      {
        JProperty(1) 
        {
          JObject(2) 
          {
            JProperty(1) 
            {
              [ContentVersion] 
            },
            JProperty(1) 
            {
              [/services/data/v49.0/sobjects/ContentVersion/0681e000001njiyAAA] 
            }
          }
        },
        JProperty(1) 
        {
          [0681e000001njiyAAA] 
        },
        JProperty(1) 
        {
          [0691e000001nhekAAA] 
        },
        JProperty(1) 
        {
          [True] 
        },
        JProperty(1) 
        {
          [] 
        },
        JProperty(1) 
        {
          [05T1e0000066OZBEA2] 
        },
        JProperty(1) 
        {
          [1] 
        },
        JProperty(1) 
        {
          [23000012] 
        },
        JProperty(1) 
        {
          [] 
        },
        JProperty(1) 
        {
          [] 
        },
        JProperty(1) 
        {
          [A] 
        },
        JProperty(1) 
        {
          [N] 
        },
        JProperty(1) 
        {
          [23000012] 
        },
        JProperty(1) 
        {
          [0] 
        },
        JProperty(1) 
        {
          [False] 
        },
        JProperty(1) 
        {
          [03/22/2024 15:18:27] 
        },
        JProperty(1) 
        {
          [0051e000005FBqYAAW] 
        },
        JProperty(1) 
        {
          [0] 
        },
        JProperty(1) 
        {
          [0] 
        },
        JProperty(1) 
        {
          [] 
        },
        JProperty(1) 
        {
          [] 
        },
        JProperty(1) 
        {
          [INR] 
        },
        JProperty(1) 
        {
          [0051e000005FBqYAAW] 
        },
        JProperty(1) 
        {
          [0051e000005FBqYAAW] 
        },
        JProperty(1) 
        {
          [03/22/2024 15:18:27] 
        },
        JProperty(1) 
        {
          [0051e000005FBqYAAW] 
        },
        JProperty(1) 
        {
          [03/22/2024 15:18:27] 
        },
        JProperty(1) 
        {
          [03/22/2024 15:18:28] 
        },
        JProperty(1) 
        {
          [] 
        },
        JProperty(1) 
        {
          [UNKNOWN] 
        },
        JProperty(1) 
        {
          [R] 
        },
        JProperty(1) 
        {
          [/services/data/v49.0/sobjects/ContentVersion/0681e000001njiyAAA/VersionData] 
        },
        JProperty(1) 
        {
          [45594] 
        },
        JProperty(1) 
        {
          [] 
        },
        JProperty(1) 
        {
          [0051e000005FBqYAAW] 
        },
        JProperty(1) 
        {
          [C] 
        },
        JProperty(1) 
        {
          [] 
        },
        JProperty(1) 
        {
          [S] 
        },
        JProperty(1) 
        {
          [] 
        },
        JProperty(1) 
        {
          [] 
        },
        JProperty(1) 
        {
          [] 
        },
        JProperty(1) 
        {
          [5527dc5588e4ccb156e9bc55bbaa8468] 
        },
        JProperty(1) 
        {
          [True] 
        },
        JProperty(1) 
        {
          [False] 
        }
      }
    },
    JProperty(1) 
    {
      JObject(1) 
      {
        JProperty(1) 
        {
          [Fri,
          22 Mar 2024 09:48:28 GMT] 
        }
      }
    },
    JProperty(1) 
    {
      [200] 
    },
    JProperty(1) 
    {
      [contentVersionRecord] 
    }
  },
  JObject(4) 
  {
    JProperty(1) 
    {
      JObject(3) 
      {
        JProperty(1) 
        {
          [06A1e000003AjiTEAS] 
        },
        JProperty(1) 
        {
          [True] 
        },
        JProperty(1) 
        {
          JArray(0) 
          {
            
          }
        }
      }
    },
    JProperty(1) 
    {
      JObject(1) 
      {
        JProperty(1) 
        {
          [/services/data/v49.0/sobjects/ContentDocumentLink/06A1e000003AjiTEAS] 
        }
      }
    },
    JProperty(1) 
    {
      [201] 
    },
    JProperty(1) 
    {
      [refCDL] 
    }
  }
}

}
}

@shameenapatel74,

try like this.

yourjasondeserializedvariable.ToString

This will give you readable values from this you can get the keys to lookout for like this.

yourjasondeserializedvariable(“compositeResponse”).ToString

I think you will have to do to deserialize of this 9key as well. Use this code to get that data into a dictionary.

dictionaryVariable = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(yourjasondeserializedvariable("compositeResponse").ToString)

Thanks,
Ashok :slight_smile:

I tried this method. Got this error.

Assign: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type ‘System.Collections.Generic.Dictionary`2[System.String,System.Object]’ because the type requires a JSON object (e.g. {“name”:“value”}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {“name”:“value”}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path ‘’, line 1, position 1.
[/quote]

I tried this method. Got this error.

Assign: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type ‘System.Collections.Generic.Dictionary`2[System.String,System.Object]’ because the type requires a JSON object (e.g. {“name”:“value”}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {“name”:“value”}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path ‘’, line 1, position 1.

@shameenapatel74,

Did you get json string with this yourjasondeserializedvariable(“compositeResponse”).ToString ?

Yes. I got below below string

@"[

{
““body””:
{
““totalSize””: 1,
““done””: true,
““records””: [

{
  ""attributes"": 
  {
    ""type"": ""Order__c"",
    ""url"": ""/services/data/v59.0/sobjects/Order__c/a0T1e000001ZVbyEAG""
      
  },
  ""Id"": ""a0T1e000001ZVbyEAG"",
  ""Name"": ""OC-1066"",
  ""OwnerId"": ""0055j000002IMmBAAW""
    
}]

},
““httpHeaders””:
{

},
““httpStatusCode””: 200,
““referenceId””: ““orders””

},

{
““body””: null,
““httpHeaders””:
{

},
““httpStatusCode””: 204,
““referenceId””: ““orderRecord””

},

{
““body””:
{
““id””: ““0681e000001njodAAA””,
““success””: true,
““errors””:

},
““httpHeaders””:
{
““Location””: “”/services/data/v49.0/sobjects/ContentVersion/0681e000001njodAAA""

},
““httpStatusCode””: 201,
““referenceId””: ““contentVersion””

},

{
““body””:
{
““attributes””:
{
““type””: ““ContentVersion””,
““url””: “”/services/data/v49.0/sobjects/ContentVersion/0681e000001njodAAA""

},
""Id"": ""0681e000001njodAAA"",
""ContentDocumentId"": ""0691e000001nhkOAAQ"",
""IsLatest"": true,
""ContentUrl"": null,
""ContentBodyId"": ""05T1e0000066OlMEAU"",
""VersionNumber"": ""1"",
""Title"": ""23000012"",
""Description"": null,
""ReasonForChange"": null,
""SharingOption"": ""A"",
""SharingPrivacy"": ""N"",
""PathOnClient"": ""23000012"",
""RatingCount"": 0,
""IsDeleted"": false,
""ContentModifiedDate"": ""2024-03-22T16:30:55+05:30"",
""ContentModifiedById"": ""0051e000005FBqYAAW"",
""PositiveRatingCount"": 0,
""NegativeRatingCount"": 0,
""FeaturedContentBoost"": null,
""FeaturedContentDate"": null,
""CurrencyIsoCode"": ""INR"",
""OwnerId"": ""0051e000005FBqYAAW"",
""CreatedById"": ""0051e000005FBqYAAW"",
""CreatedDate"": ""2024-03-22T16:30:55+05:30"",
""LastModifiedById"": ""0051e000005FBqYAAW"",
""LastModifiedDate"": ""2024-03-22T16:30:55+05:30"",
""SystemModstamp"": ""2024-03-22T16:30:56+05:30"",
""TagCsv"": null,
""FileType"": ""UNKNOWN"",
""PublishStatus"": ""R"",
""VersionData"": ""/services/data/v49.0/sobjects/ContentVersion/0681e000001njodAAA/VersionData"",
""ContentSize"": 45594,
""FileExtension"": null,
""FirstPublishLocationId"": ""0051e000005FBqYAAW"",
""Origin"": ""C"",
""NetworkId"": null,
""ContentLocation"": ""S"",
""TextPreview"": null,
""ExternalDocumentInfo1"": null,
""ExternalDocumentInfo2"": null,
""Checksum"": ""5527dc5588e4ccb156e9bc55bbaa8468"",
""IsMajorVersion"": true,
""IsAssetEnabled"": false

},
““httpHeaders””:
{
““Last-Modified””: ““Fri,
22 Mar 2024 11:00:56 GMT””

},
““httpStatusCode””: 200,
““referenceId””: ““contentVersionRecord””

},

{
““body””:
{
““id””: ““06A1e000003AjqhEAC””,
““success””: true,
““errors””:

},
““httpHeaders””:
{
““Location””: “”/services/data/v49.0/sobjects/ContentDocumentLink/06A1e000003AjqhEAC""

},
““httpStatusCode””: 201,
““referenceId””: ““refCDL””

}]"

we recommend to share with us the complete JSON as a text file.
For any further assistance let us in detail know which value(s) are to extract

For the more visual representation we add toString() on the parsed JObject/JArray

Prototyping / RND we can do directly within the immediate panel

“{"compositeResponse":[{"body":{"totalSize":1,"done":true,"records":[{"attributes":{"type":"Order__c","url":"/services/data/v59.0/sobjects/Order__c/a0T1e000001ZVbyEAG"},"Id":"a0T1e000001ZVbyEAG","Name":"OC-1066","OwnerId":"0055j000002IMmBAAW"}]},"httpHeaders":{},"httpStatusCode":200,"referenceId":"orders"},{"body":null,"httpHeaders":{},"httpStatusCode":204,"referenceId":"orderRecord"},{"body":{"id":"0681e000001njqPAAQ","success":true,"errors":},"httpHeaders":{"Location":"/services/data/v49.0/sobjects/ContentVersion/0681e000001njqPAAQ"},"httpStatusCode":201,"referenceId":"contentVersion"},{"body":{"attributes":{"type":"ContentVersion","url":"/services/data/v49.0/sobjects/ContentVersion/0681e000001njqPAAQ"},"Id":"0681e000001njqPAAQ","ContentDocumentId":"0691e000001nhmAAAQ","IsLatest":true,"ContentUrl":null,"ContentBodyId":"05T1e0000066OokEAE","VersionNumber":"1","Title":"23000012","Description":null,"ReasonForChange":null,"SharingOption":"A","SharingPrivacy":"N","PathOnClient":"23000012","RatingCount":0,"IsDeleted":false,"ContentModifiedDate":"2024-03-22T11:19:03.000+0000","ContentModifiedById":"0051e000005FBqYAAW","PositiveRatingCount":0,"NegativeRatingCount":0,"FeaturedContentBoost":null,"FeaturedContentDate":null,"CurrencyIsoCode":"INR","OwnerId":"0051e000005FBqYAAW","CreatedById":"0051e000005FBqYAAW","CreatedDate":"2024-03-22T11:19:03.000+0000","LastModifiedById":"0051e000005FBqYAAW","LastModifiedDate":"2024-03-22T11:19:03.000+0000","SystemModstamp":"2024-03-22T11:19:03.000+0000","TagCsv":null,"FileType":"UNKNOWN","PublishStatus":"R","VersionData":"/services/data/v49.0/sobjects/ContentVersion/0681e000001njqPAAQ/VersionData","ContentSize":45594,"FileExtension":null,"FirstPublishLocationId":"0051e000005FBqYAAW","Origin":"C","NetworkId":null,"ContentLocation":"S","TextPreview":null,"ExternalDocumentInfo1":null,"ExternalDocumentInfo2":null,"Checksum":"5527dc5588e4ccb156e9bc55bbaa8468","IsMajorVersion":true,"IsAssetEnabled":false},"httpHeaders":{"Last-Modified":"Fri, 22 Mar 2024 11:19:03 GMT"},"httpStatusCode":200,"referenceId":"contentVersionRecord"},{"body":{"id":"06A1e000003AjtREAS","success":true,"errors":},"httpHeaders":{"Location":"/services/data/v49.0/sobjects/ContentDocumentLink/06A1e000003AjtREAS"},"httpStatusCode":201,"referenceId":"refCDL"}]}”

This is the json string i got from API call and i want to extract the last httpStatusCode value from this json

ensure that the JSON you share with us is valid. Use JSON LINT or other tools

we fixed above for the “errors”: null ← and added

grafik

@shameenapatel74,

Here is the logic to get that status code.

Code here for reference.
JsonValue.xaml (11.8 KB)

image

Thanaks,
Ashok :slight_smile:

how did you got strJson string value?

@shameenapatel74,

From your question.