Skip to content

Uploading data

APIs can also be used to upload encoded content to a server such as application/json for content in JSON format and multipart/form-data for uploading files.

Templating is enabled on every content type.

Sync header's content type

Content type can be set on the Body tab and automatically be replaced on the header. For this, there should be a Content-Type header with value {{ ctx.auto() }}.

content type auto

Content type

None

In order to send no body use the None Content-Type. This special content type will not be sent on headers if it's value is {{ ctx.auto() }}.

body none

JSON, XML or other text-based content

body text

Or more complex rendering

body xml

Form types

Form types are supported under:

  • multipart/form-data
  • application/x-www-form-urlencoded

body form

Uploading a file

Set the content type to multipart/form-data.

{{ ctx.load_file('my_file.txt') }}

The mime type is automatically inferred to change it, use the parameter mime_type.

{{ ctx.load_file('my_file.txt', mime_type='text/plain') }}

body file

Custom types

It's possible to write a custom tab on the Body tab. For this Content-Type header with value {{ ctx.auto() }}.

body custom