8

thanks for your time I have a POST request that I want to document in the blueprint apiary, the header is something like this:

text/html

_method:POST

data[User][username]:

data[User][password]:

data[User][remember]:0

http://d.pr/i/uRFx

I have something like this but I am not sure how to finish it:

## login [/users/login/{username}{password}{remember}{ident}]
Login with a user and password

+ Parameters

    + username (required, string, `myname`) ... the username format should follow CakePHP: data[User][username].
    + password (required, string, `whatever`) ... the password format should follow CakePHP: data[User][password]
    + remember (required, number, `0`) ... the remember format should follow CakePHP: data[User][remember]
    + ident (optional, number, `0`) ... the ident format should follow CakePHP: data[User][ident]

### make login [POST]

+ login by user (text/plain)
What goes in here???????????

any idea? Thanks!

Zdenek
  • 3,523
  • 25
  • 34
lito
  • 2,792
  • 9
  • 40
  • 68
  • Is this an URL-encoded form? Can you please click "view source" in your inspector (the screenshot you have attached). Also note there is the [cURL trace parser](https://github.com/apiaryio/curl-trace-parser) which can record a communication directly into API Blueprint – Zdenek Nov 07 '13 at 19:38
  • I really don't understand what you mean but this is the compleate screen shot of the request: http://d.pr/i/L256 – lito Nov 07 '13 at 19:45
  • BTW, this is the encode: http://d.pr/i/k6bS – lito Nov 07 '13 at 19:55

1 Answers1

12

Apparently this is submitting the data in a web form. In this case the Content-Type is of the application/x-www-form-urlencoded type.

The message-body of the request has special formatting and also some of its charters (square brackets) have to be %-escaped. For the details on the formatting of the request body see aforementioned Wiki article.

The API Blueprint in its simplest form could be something like:

# Login [/users/login]
## Make Login [POST]
+ Request (application/x-www-form-urlencoded)

        data%5BUser%5D%5Busername%5D=qq&data%5BUser%5D%5Bpassword%5Dqq&data%5BUser%5D%5Bremember%5D=0

+ Response 201

You should be able to see your example of request message-body in your traffic inspector under the "view URL encoded" link.

Refer to this blueprint to see this example in action.

Also refer to this SO question for further details on application/x-www-form-urlencoded.

Community
  • 1
  • 1
Zdenek
  • 3,523
  • 25
  • 34
  • Thanks! great! now I understand!. – lito Nov 07 '13 at 20:09
  • can you please post here the blueprint-markup of this??? -http://docs.urlencoded.apiary.io/ there are many missing samples of the blueprint and this one is really help full for me. Thanks! – lito Nov 07 '13 at 20:09