Uploading data

APIs can also be used to upload encoded content to a server. This is usually done with PUT or POST methods.

The most common content types are:

  • application/json: for content in JSON format
  • multipart/form-data: for uploading encoded files

Uploading a file

Let us take a look at uploading an image file into an API using hoppscotch.

To upload a file, the data you send in a POST request must be of the content types application/x-www-form-encoded and multipart/form-data.

Uploading an image

  1. Select the POST HTTP method and set your API Endpoint URL
  2. Add the necessary headers
  3. To add your image file click in the body tab and select multipart/form-data in the content-type dropdown
  4. Give your file a name and click on choose files to select your file
  5. Click "Send" to upload your file