how to format a POST request on apiary.io?
Asked Answered
B

1

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!

Blayze answered 7/11, 2013 at 15:57 Comment(3)
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 which can record a communication directly into API BlueprintCredential
I really don't understand what you mean but this is the compleate screen shot of the request: d.pr/i/L256Blayze
BTW, this is the encode: d.pr/i/k6bSBlayze
C
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.

Credential answered 7/11, 2013 at 20:1 Comment(1)
can you please post here the blueprint-markup of this??? -docs.urlencoded.apiary.io there are many missing samples of the blueprint and this one is really help full for me. Thanks!Blayze

© 2022 - 2024 — McMap. All rights reserved.