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

Test with POST data #149

Open
AndreaCrotti opened this issue Jun 16, 2016 · 6 comments
Open

Test with POST data #149

AndreaCrotti opened this issue Jun 16, 2016 · 6 comments

Comments

@AndreaCrotti
Copy link

I'm trying to test a simple API that takes an email in the POST data and return something else.
So I defined my raml file like this:

/abao-check/:
  post:
    body:
      application/x-www-form-urlencoded:
        example: |
          {"email": "[email protected]"}

    responses:
      201:
        body:
          application/json:
            schema: |
              {
                "$schema": "http://json-schema.org/draft-03/schema",
                "type": "object",
                "required": ["email"],
                "properties": {"email": {"type": "string"}}
              }

but no matter what I do it doesn't seem it's never putting any body in request.POST.
Any idea why?

Am I missing something obvious?
by the way I think it would be great to have some examples of RAML files to test in this project, would make it easy to see what it can be done..
Thanks a lot!

@plroebuck
Copy link
Collaborator

plroebuck commented Jun 17, 2016

Abao doesn't currently support form-based submissions (a.k.a. application/x-www-form-urlencoded),
only JSON-based media types.

As far as examples go, there are RAML/schema files in the test/fixtures folder.

@plroebuck
Copy link
Collaborator

Sorry. I wrote response yesterday, but left without posting it.

@AndreaCrotti
Copy link
Author

Ah ok thanks no problem @plroebuck I'll close the issue, is it a feature you want to implement anyway?

@coltonlw
Copy link
Contributor

@AndreaCrotti Abao support for url-encoded form data is something I hope to see added eventually as well, and I will contribute to that feature if I can. However I think in your case the problem is with the way you defined your specification. The data in your request example is clearly JSON, so I would recommend changing your specification to use a content-type of application/json:

/abao-check/:
  post:
    body:
      application/json:
        example: |
          {"email": "[email protected]"}

If that endpoint actually does accept a url-encoded form with an "email" field, putting JSON as the example for the request body is confusing. This tutorial on raml.org gives an example of how to document a form (using formParameters directive). http://raml.org/developers/raml-200-tutorial#body-parameters

@AndreaCrotti
Copy link
Author

This is still an open issue right @coltonlw ?

@coltonlw
Copy link
Contributor

coltonlw commented Oct 2, 2016

@AndreaCrotti I believe so, we are using Postman collections run via newman CLI runner for postman to test url encoded or multipart form data and file uploads

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

4 participants