json - 可以使用 curl 上传外部 json 文件而不是 --data 吗?

标签 json rest curl

通过 curl 测试 REST POST api 时,是否可以从外部 json 文件发送数据,而不是通过 --data 内联?

最佳答案

要指定文件中的数据,请使用 --data @filename。从 curl 的手册页:

If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin. The contents of the file must already be URL-encoded. Multiple files can also be specified. Posting data from a file named 'foobar' would thus be done with --data @foobar.

关于json - 可以使用 curl 上传外部 json 文件而不是 --data 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10427616/

相关文章:

javascript - D3 world-50m.json 投影填充错误

json - Logstash读取CSV及其JSON对象

java - 问题 : java. lang.UnsupportedClassVersionError: org/glassfish/jersey/servlet/ServletContainer

curl - 为什么 curl 在 mac 上使用 HTTP/1.1 而不是 HTTP/2?

JavaScript 将字符串拆分为具有属性的对象

javascript - 如何在表格中显示json字符串的多维数组

java - 使用 Jersey JAX-RS 时,有没有办法区分作为 null 发送的字段和根本不发送的字段?

c# - RESTful WCF 服务返回 "The resource cannot be found."错误

node.js - Curl 和 Postman 给出不同的响应?

php - 使用curl在本地获取.php文件