简体   繁体   English

与CURL一起使用,如何格式化Postman / REST客户端

[英]Works with CURL how to format for Postman/REST client

I'm sure this is a dumb question but I haven't been able to see the light. 我敢肯定这是一个愚蠢的问题,但我还没能看到光。

If I have a curl command ... 如果我有curl命令...

curl -v  -F "dataType=dws" -F "format=csv" -F "compression=gzip" -F "sha256sum=17685b28be3af7b71bcab78c0393d548d7cd563f3fd5d955309c9512a4ad28ad" -F "file=@/Users/xxx/sql/file.gz" http://localhost:8080/p20/fileUpload

that works perfectly, how do I do the same thing via Postman(or any REST client) ? 完美地工作,如何通过Postman(或任何REST客户端)执行相同的操作?

Thanks in advance for enlightening me. 在此先感谢您的启发。

tF means Formdata. tF表示Formdata。 Normally used for the data from the form fields of a HTML page, which are typically submitted by an POST Request to the server. 通常用于HTML页面表单字段中的数据,通常由POST请求提交给服务器。 Curl builds a data string and send it in the body of the HTTP request. Curl构建一个数据字符串,并将其发送到HTTP请求的正文中。 An equivalent to your curl statement is: 与curl语句等效的是:

curl -v -X POST -d "dataType=dws&format=csv&compression=gzip&sha256sum=17685b28be3af7b71bcab78c0393d548d7cd563f3fd5d955309c9512a4ad28ad&file=@/Users/xxx/sql/file.gz" http://localhost:8080/p20/fileUpload

curl treats the file=@... as a special command. curl将file = @ ...视为特殊命令。 It reads the file and appends the content to the body. 它读取文件并将内容附加到正文。 It also set the mime type to multipart/formdata . 还将mime类型设置为multipart/formdata

Thats all you must do in postman or equivalent. 那就是您在邮递员或同等职位中必须做的所有事情。 Enter the string after -d in the body/content field. 在正文/内容字段的-d之后输入字符串。 Set the method to POST. 将方法设置为POST。 Enter the URL. 输入URL。

-v increases the verbosity level. -v增加详细程度。 I don't know how to make postman more verbose. 我不知道如何使邮递员更加冗长。

There is an excellent blog post on Postman.com that gives detailed step by step instructions to turn on verbose mode in postman application. 在Postman.com上有一篇很棒的博客文章 ,其中提供了详细的逐步说明,以在Postman应用程序中打开详细模式。 This allows you to observe raw HTTP requests and also do much more debugging. 这使您可以观察原始的HTTP请求,还可以进行更多的调试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM