Skip to main content
gauravp9819
September 11, 2023
Question

Index not working

  • September 11, 2023
  • 5 replies
  • 0 views

I have an HttpResponse type pv holding following value:

[statusLine=HTTP/1.1 500 Internal Server Error, statusCode=500, headers=[object Object], contentType=application/json, body={"type":""title":"Internal">www.w3.org/.../rfc2616-sec10.html","title":"Internal Server Error","status":500,"detail":"Error connecting to underlying system","instance":"XXXXX/error/uuid:XXXXxXXXXXXXXXX"}]

I am passing it to and expression rule and indexing "body" into a local variable responseBody , which is wprking ok, However when I try to index any of the attributes within body , such as "title", "type","detail","status", Index is not working and returning default value. I am trying as follows:

errorDescription: if(ri!success,"",if(a!isNullOrEmpty(local!responseBody),"",index(local!responseBody,"type",""))),

Checked runtime type of local!responseBody and it is AnyType,

Any thoughts suggestions? PS HttpResponse is  captures in AC!Result in an Integration node in PM.

This is quite strange , any inputs would be appreciated.

5 replies

stefanhelzle0001
Brainy
September 11, 2023

Could it be that you pass the data as a string instead of parsing the JSON to a data structure?

gauravp9819
September 11, 2023

I was thinking like that ,but I have not parsed that part to a cdt etc.There is no indication of this coming in as text , it seemed a dictionary to me.

Is there anyway to do it without creating a body cdt as body for success will be different than what i see for error response.

stefanhelzle0001
Brainy
September 11, 2023

The data you posted shows clearly that the JSON is just a string. You can see that by the curly brackets. Appian uses angular brackets to visualize data structures. I highly recommend to add a map type parameter to your process model and use a!fromJson to pass the data. Then you indexing will work.

September 12, 2023

Hi gpandey,

body is coming back on json format, try to wrap body in a!fromJson, so that you can use index 

and also i see improper " in the body. please make sure from service side you are getting response in proper Json format

gauravp9819
September 12, 2023

Thank you both for your suggestions.I had managed it using a!fromJson and then using index