cancel
Showing results for 
Search instead for 
Did you mean: 

How to change default array document structure?

ddangler
New Contributor III

I am working with Zendesk API and one of its endpoint expect document structure as below:

{
  "tickets": [
    { "id": 1, "status": "solved" },
    { "id": 2, "status": "pending" }
  ]
}

But snaplogic is sending data like this:

[
	{
	  "tickets": [
	    { "id": 1, "status": "solved" },
	    { "id": 2, "status": "pending" }
	  ]
	}
]

How can I remove those extra square brackets at the beginning and the end?

I played around with the HTTP Entity setting in the REST PUT snap but could not get it work. Any help here?

Here is the screenshot showing what I am trying to acheive:

Selection_303

3 REPLIES 3

ddangler
New Contributor III

Any help here? Thanks in Advance!

The preview shows the since multiple documents can be streamed, each document being streamed is a map. The REST POST snap will take each document and write it out to the endpoint, as a map. You can change the POST endpoint to a test endpoint created in a service like https://requestb.in/, to verify whether the right data is being posted.

The Zendesk API error response would have more details. It is possible the right content type was not set, add a HTTP Header in the POST snap, with key “Content-Type” and value “application/json”

ddangler
New Contributor III

You are right. Everything seem to be fine except for the missing ‘Content-Type’ header. Once I added that it is working fine.

I wish Zendesk API error response had more details as you expected but it is not. I am so tired of Zendesk API 😫