Andrew Majskiy
Posts: 0
Joined: Fri Jan 04, 2013 1:31 pm

POST request

Hello! I am trying to create Service with POST request. According to API documentation I have next example:
http://easycaptures.com/fs/uploaded/5...
Also it require two params:
http://easycaptures.com/fs/uploaded/5...
So according this example and required params I created request:
http://easycaptures.com/fs/uploaded/5...
In Test tab I have next result:
http://easycaptures.com/fs/uploaded/5...
Settings:
http://easycaptures.com/fs/uploaded/5...
What can be the reason of my error? Or maybe I made any mistake?
Thanks!

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

POST request

I think this image: http://easycaptures.com/fs/uploaded/5... shows the JSON response.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

POST request

Hello! You use carepass.com REST API. It requires to send data as an array in data variable of ajax request. In Tiggzi you can send data as an object. That's why you get Json parsing error. Occurs at line=1, column=1 error. The workaround is do not use Tiggzi services and just send request through

code$.ajax({
contentType: 'application/json',
data: JSON.stringify([{ "sourceType": "Device", "type": "Running"........... }]),
...............
})/code

Andrew Majskiy
Posts: 0
Joined: Fri Jan 04, 2013 1:31 pm

POST request

But in case other POST request which has next structure
Image
it works well without JSON.stringify

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

POST request

Hello! Please take a look at this screenshot http://easycaptures.com/fs/uploaded/5...

Symbols "[" "]" in the begining and in the end mean that you send an array with an object, but you can't send array in Tiggzi (just an object). That's why you have to do this using

code$.ajax({
......
data: JSON.stringify([{....}])
....
})/code

Most likely other POST request do not require to send an array.

Return to “Issues”