Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for supplying POST, DELETE and PUT parameters in the HTTP request body instead of GET parameters #33

Merged
merged 6 commits into from
Aug 15, 2012

Conversation

martintajur
Copy link
Contributor

I've implemented support for POST, DELETE and PUT request parameters as part of HTTP request body instead of supplying them as GET parameters.

Previously, for example, when supplying parameters for a POST request, these parameters got attached to the request as GET parameters not as part of the request body as per HTTP specification. This patch addresses this issue.

EDIT: I also added a support for EnumeratedDescription which enables a better way to describe enumerated field values. It renders the possible enumerated field values with descriptions as a definition list below the field description.

Please review and discuss, hope it finds good use :)

@martintajur
Copy link
Contributor Author

I also added a support for EnumeratedDescription which enables a better way to describe enumerated field values. It renders the possible enumerated field values with descriptions as a definition list below the field description.


35. "Type" key value is *boolean* that will render a drop-down (select box) on the form for *true* and *false*.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 35 seemed like a typo in the readme.

@jplock
Copy link
Contributor

jplock commented Aug 5, 2012

+1, I hope this gets merged in.

@whump
Copy link

whump commented Aug 7, 2012

It would also be useful to set the content type of POST and PUT bodies for APIs that only handle XML content.

@mansilladev
Copy link
Contributor

I'm going to merge this in. I think a fast follow to this might be JSON encoding (JSON.stringify) with application/json content-type, eh? Thanks for your work on this. Love it.

mansilladev added a commit that referenced this pull request Aug 15, 2012
Support for supplying POST, DELETE and PUT parameters in the HTTP request body instead of GET parameters; enumerated descriptions feature.
@mansilladev mansilladev merged commit 7ac39c7 into mashery:master Aug 15, 2012
};

if (['POST','DELETE','PUT'].indexOf(httpMethod) !== -1) {
var requestBody = query.stringify(params);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone is looking for using a body in JSON format, this needs to be changed to JSON.stringify(params);

query.stringify(params) will return something like

value=someval

JSON.stringift(params) will return

{"value":"someval"}

Otherwise, you'll throw a parse error on the server-side which is expecting a JSON format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants