Uploading a file using Postman

Published by Tobias Hofmann on

3 min read

I had to use Postman to upload a file to the FSCrawler REST service. The rest service is running under the following URL: http://192.168.7.77:3344/fscrawler/_document. The FSCrawler docs explain how to use the command for curl. The only challenge was to translate the given information into the Postman UI.

curl -F "file=@test.txt" http://127.0.0.1:8080/fscrawler/_upload

The parameter -F means that the file is send via form. This is explained in detail in the curl manpage.

“For HTTP protocol family, this lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-data according to RFC 2388.”

[curl manpage]

For Postman this means:

  1. POST request
  2. Header for Content-Type is multipart/form-data
  3. Provide binary file as file parameter

Postman

Request

POST http://192.168.7.77:3344/fscrawler/_document

The doc says _upload, but in my ElasticSearch version 7.17.1 I get told by ES that _upload is deprecated and that _document should be used. As the FSCrawler REST service is “just” a proxy for ES requests, it is possible to change the URL and use _document.

Header

Body

Type: form-data

Key: file

Attention: also select from dropdown: File

With File selected, a file selector appears und value,

In the file selection dialog that is shown any file can be selected and added to the request.

Result

Nothing else is needed to send a single file. The code snippet for curl reveals that the request matches the FSCrawler documentation.

Let the world know

Tobias Hofmann

Doing stuff with SAP since 1998. Open, web, UX, cloud. I am not a Basis guy, but very knowledgeable about Basis stuff, as it's the foundation of everything I do (DevOps). Performance is king, and unit tests is something I actually do. Developing HTML5 apps when HTML5 wasn't around. HCP/SCP user since 2012, NetWeaver since 2002, ABAP since 1998.

1 Comment

Vikas · June 13, 2022 at 08:43

thanks, would like to add, If you get SSL error, disable it from settings

Source: https://qawithexperts.com/article/web-api/upload-or-send-file-in-postman/438

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.