如何使用cURL post请求在数据原始负载中以字符串形式发送文件内容



下面是我发送后请求的curl查询

在";有效载荷";json数据的键,我需要发送作为值的1MB文本数据的文件。与其将整个文本作为字符串复制,不如将文本作为字符串从驱动器中本地保存的文件中复制。

curl --location --request POST 'http://localhost:8080/test' 
--header 'Content-Type: application/json' 
--data-raw '{
"fileFormat":"csv",
"version":"v1",
"payload":"<local file content should come here>",
} 

将数据负载放入文件中,并尝试使用以下方法:curl --location --request POST 'http://localhost:8080/test' --header 'Content-Type: application/json' --d @/path/to/filename.json。希望这能解决你的问题

最新更新