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

How can I send POST data as JSON? #54

Open
gregeinfrank opened this issue Oct 28, 2014 · 7 comments
Open

How can I send POST data as JSON? #54

gregeinfrank opened this issue Oct 28, 2014 · 7 comments

Comments

@gregeinfrank
Copy link

Hi,

When using the UI (api/spec.html) I want to test out my endpoints by sending in POST data in the form of application/json. The ui does show that the content type is application/json

image

But when I click "Try it out!" it doesn't actually create a JSON object with the param name as the key, it just sends the parameter as plain text. Does anyone know how to get the ui to send the parameters as formatted json objects?

Thanks!

@sebastianneubauer
Copy link

Maybe similar problem here, what about basic authentication header? Is is possible to send it from the ui?

@lukas-gitl
Copy link

Possibly similar issue: When you select paramType=query for a POST request and then "try" the api through the generated html, the parameters are actually appended to the url (as you'd expect for a GET request). Love all the rest so far, but that bug is really putting me off :/

@lounagen
Copy link

Hi,
Extracted from the swagger spec ( https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#parameterObject ):

@lukas-gitl : that's the expected behaviour of a query param:
Query - Parameters that are appended to the URL. For example, in /items?id=###, the query parameter is id.

@gregeinfrank : The body param type seems to be the payload "as-is" (not re-interpreted). I didn't test it by myself but may be the paramType for a form (formData instead of body) will do it according your application/json content-type (swagger spec shows samples only for application/x-www-form-urlencoded and multipart/form-data) ?

@mserralta
Copy link

mserralta commented Feb 22, 2017

If your "facebook_token" is not a JSON object but a primitive object (string, integer, etc.) try form as parameter's type instead of body

@igormcsouza
Copy link

igormcsouza commented Nov 19, 2020

Well! I had to sent on the value box the actual JSON I wanted to send. Instead of just the value! Just like

{ "key": "value" }

I think is a miss understand from my part or maybe a very tricky situation!

It wouldn't be better if we could send just the value and the wrapper auto generate the JSON to send to the request? I guess it would be more straight forward! I guess deal with multiple parameters will be a really pain in a back side!

@igormcsouza
Copy link

@rantav ... I really would like to help on this situation! But I'm not getting where those arguments are configured! I'm still looking for it, but if you have any time, please point me where I can start to change that? I'd be grateful!

@niall-byrne
Copy link
Collaborator

Can you post a snippet of example code to demo what you're trying to do?

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

No branches or pull requests

7 participants