post json data
Closed this issue · 5 comments
Hi,
It is possible to POST json data?
(A post with 'contentType: application/json' and with json body)
Hi.
Of course. Set {method: 'post', parameters: {anything}} and it will be sent as JSON. To recieve JSON properly, it's need to be also set json: true explicitly.
If this didn't help, try to write some code here, what you want to see that it should work, and I'll try to give you working analog.
i have:
marmottajax({url:"/proxy/...", method: 'POST', parameters : {foo:{bar: 10}} })
I'm getting an error in my framework:
[Expecting text/json or application/json body]
Also the marmottajax are putting the request header: Content-Type:application/x-www-form-urlencoded
I should be able to set application/json
@ruioliveiras really. It forces "x-www...". You're able to set "headers" option to {'Content-Type': 'application/json'} and it should rewrite the defaults. But I'll check it today and fix, if it does not.
I guess, the error is just framework's because the header isn't OK?
Just saw this issue. I just made a pull request (#19) that may be what you need @ruioliveiras
@dlid hi! The fork for next version is created now: https://github.com/houd1ni/Marmott2