how to format a POST request on apiary.io?

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!


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 .

链接地址: http://www.djcxy.com/p/22156.html

上一篇: 为什么我无法从POST请求中提取zip文件?

下一篇: 如何格式化apiary.io上的POST请求?