Page 4 of 4

Post request

Posted: Mon Mar 11, 2013 8:29 am
by Joseph Yeung

Hi, Tiggzi team,

It turns out that I tried out Tiggzi UI again to call the Tiggzi database service. It worked and returned in the network:

Image

Whereas if custom javascript is used, it returned in the network:
Image

So, it comes down to the "Accept" parameter?? Please anyone advise.


Post request

Posted: Mon Mar 11, 2013 9:12 am
by Maryna Brodina

Hello! Working on it... I'll update as soon as I get any information.


Post request

Posted: Mon Mar 11, 2013 9:45 am
by Maryna Brodina

codeRequest Payload
question=&question=abc&choice1=&choice2=&choice3=&choice4=&answer=&explanation=sads+/code

you send data with x-www-form-urlencoded type, not json - it could be cause of Internal Server Error.

Data in json format should look like this:

code{"question":"","choice1":"","choice2":"","choice3":"","choice4":"","answer":"","explanation":"sads+"}/code


Post request

Posted: Mon Mar 11, 2013 10:52 am
by Joseph Yeung

Hi,Marina,

I just now tried set the set the header:
code
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
/code

The network sent serialized data request in x-www-form-urlencoded type alright, but still the request failed.

What else can I do along this line of "x-www-form-urlencoded" request? or I should try other directions?

Thx!


Post request

Posted: Mon Mar 11, 2013 11:25 am
by Joseph Yeung

It seems that the "Accept" parameter as shown in the network information above must have to do with the failure/ success.

What do you think?


Post request

Posted: Mon Mar 11, 2013 11:40 am
by Maryna Brodina

You can use "Accept" parameter as header. You just need to send data on server in json format, not in application/x-www-form-urlencoded.

Set Content-Type:application/json, also you would need to expose data in json format


Post request

Posted: Mon Mar 11, 2013 11:59 am
by Joseph Yeung

I don't get it. What do you suggest?


Post request

Posted: Mon Mar 11, 2013 12:15 pm
by Maryna Brodina

Sorry. I meant you can ignore Accept: / (it doesn't affect anything). All you need to do is:

1) change application/x-www-form-urlencoded' to application/json;

codexhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');/code

2) send data on server in json format

code{"question":"","choice1":"","choice2":"","choice3":"","choice4":"","answer":"","explanation":"sads+"}/code

this is not correct

codeRequest Payload
question=&question=abc&choice1=&choice2=&choice3=&choice4=&answer=&explanation=sads+/code


Post request

Posted: Mon Mar 11, 2013 12:22 pm
by Joseph Yeung

I see. I'd try.


Post request

Posted: Mon Mar 11, 2013 7:08 pm
by Joseph Yeung

Hi Marina, thank you.

It seems that your method essentially works. To conclude:
Image

If serialized form data (instead to stringify long arrays) can be used, it would be very much conducive to development. Big thanks anyway!!