Created
June 27, 2016 09:40
-
-
Save lakamsani/1ee6958e2c7fd0c41483b671cffc6b19 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== need to send this in my API's POST body === | |
{ | |
"match": { | |
"type": "Tournament" | |
}, | |
"attrs": { | |
"name": 1 | |
}, | |
"sort": { | |
"joinEndTime": 1 | |
} | |
} | |
---- defined it like this ----- | |
* @apiParam (GameSearch) {Object} match | |
* @apiParam (GameSearch) {String="Tournament","Interactive"} match.type="Tournament" | |
* @apiParam (GameSearch) {Object} attrs | |
* @apiParam (GameSearch) {String} attrs.name=1 | |
* @apiParam (GameSearch) {Object} sort | |
* @apiParam (GameSearch) {String} sort.joinEndTime=1 | |
-------- | |
Chrome is sending it like this: | |
match=&match.type=&attrs=&attrs.name=&sort=&sort.joinEndTime= |
Got this to work by changing it like this:
- @apiParam (GameSearch) {Object} match
- @apiParam (GameSearch) {Object} attrs
- @apiParam (GameSearch) {Object} sort
And setting the Content-type header to application/x-www-form-urlencoded. Using node bodyParser my server already supports either that or the application/json. Apidoc only works with application/x-www-form-urlencoded when POST'ing from its page and sends it as:
match%5Btype%5D=Tournament&attrs%5Bname%5D=1&sort%5BjoinEndTime%5D=1
My server has no problem handling it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am also facing the same problem. Although apidoc is quiet useful, it should have a way to handle JSON requests and then only I can recommend it to anyone.