Adding and Editing Form Parameters
Form parameters are used to describe the payload of an HTTP request when either
application/x-www-form-urlencoded
or multipart/form-data
is used as the content type of the request. This is the only parameter type that can be used to send files. Form parameters have a different format based on the used content type. For details, visit http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.
Adding Form Parameters
To add Form parameters, complete these steps:
- In the right Request Body Parameter section, click Switch to Form parameters. The Request Form Parameters section is displayed.
-
By default, the application/x-www-form-urlencoded content type is selected. In the Request Content Type section, click an option to change the content type:
- application/x-www-form-urlencoded: Is similar to the format of Query parameters, but as a payload. For example,
foo=1&bar=swagger -
bothfoo
andbar
are Form parameters. This is normally used for simple parameters that are being transferred. - multipart/form-data: Each parameter takes a section in the payload with an internal header. For example, for the header Content-Disposition:
form-data; name="submit-name"
, the name of the parameter issubmit-name
. This type is more commonly used for file transfers.
- application/x-www-form-urlencoded: Is similar to the format of Query parameters, but as a payload. For example,
- Click + Form parameter to add Form parameters:
- In the Name field, enter a parameter name.
- From the data type list, select a data type. By default, the data type is
string
.Note: The file/text and file/binary options are available only when the content type is multipart/form-data, which are used to send a file in the request content. - Select the array check box if the parameter is array.Note: If the data type is file/text or file/binary, this function is disabled.
- In the Description field, enter a description for the added parameter.
- In the Default value field, enter a default value.
- Select the Required check box if the parameter is required. The required parameter is displayed in bold.
- Click Save.
Editing Form Parameters
To edit an added Form parameter, complete these steps: