Webhook JSON parse array | Community
Skip to main content
November 20, 2014
Question

Webhook JSON parse array

  • November 20, 2014
  • 2 replies
  • 3001 views
Hi All,

I am trying to parse a JSON response in order to implement error handling.

My response is
[{"message":"insufficient access rights on cross-reference id: 00QN00000012BjY","errorCode":"INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY","fields":[]}]

Note that an unreferenced array is returned ( [.....] ).  If the response was {"errorCode":"errormsg"} then this would parse easily.  However, I dont have control over the system returning the message so I need to parse an array.

How do I reference the errorCode?

I have tried:
[0].errorCode
errorCode[0]
[].errorCode

But nothing I try works.  Has anyone come across this?

Thanks!


 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

November 20, 2014
I think you need to add a dot to your second one to make it work. Try:
.errorCode[0]
Chad_Caldwell
Level 1
June 22, 2017

Did you ever figure this out? Hitting same issue.

I would assume it's something like: response[0].errorCode (where "response" is the name of the returned object). This does not work just saying what I think it should be.

Thanks.

SanfordWhiteman
Level 10
June 22, 2017

Response mappings start with a dot-property of the response object. If the outermost response object is an array, you can't dereference it this way.

If you're forced to use an endpoint like this I would gateway it through something like AWS APIGW and wrap it in another object.

Responses like this aren't typically made for webhook environments.