在curl POST中使用内联数据和文件数据

nun*_*nia 2 curl http-post

我正在尝试使用curl对应用程序进行POST.我想用文件中的内联数据和数据构建数据,但我无法做到.

有谁知道这是否可能?

这是我正在尝试的代码示例:

curl -i -X POST http://localhost:3000/admin/articles -H "Content-Type: application/json" --data '{"article": {"issue_id": "1", "title": "hello", "translations_attributes": {"0": {"locale": "en", "id": "", "content": @file.json}}}}'
Run Code Online (Sandbox Code Playgroud)

Dan*_*rez 6

这更像是一种解决方法,但我认为应该在大多数弹壳中完成工作.

curl -i -X POST http://localhost:3000/admin/articles \
    -H "Content-Type: application/json" \
    --data '{"article": {"issue_id": "1", "title": "hello", 
             "translations_attributes": {"0": {"locale": "en", "id": "", 
             "content": '"`cat file.json`"'}}}}'
Run Code Online (Sandbox Code Playgroud)