Skip to main contentAPIs 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
- Select the
POST HTTP method and set your API Endpoint URL.
- Add the necessary headers.
- To add your image file click in the body tab and select
multipart/form-data in the content-type dropdown.
- Give your file a name and click on
choose files to select your file.
- Click “Send” to upload your file.