簡體   English   中英

cURL命令以POST形式嵌入請求中的數據

[英]cURL command to POST with data embedded in request

我正在編寫一個簡單的 shell腳本,當使用curl滿足條件時,將使用該腳本在JIRA中創建一個請求。 以下是JIRA的執行方式,需要我使用數據文件將發送的請求作為命令和參數發送:

請求:

curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/

數據:

{
"fields": {
   "project":
   { 
      "key": "TEST"
   },
   "summary": "REST ye merry gentlemen.",
   "description": "Creating of an issue using project keys and issue type names using the REST API",
   "issuetype": {
      "name": "Bug"
   }}}

所以我不想使用上面顯示的單獨的數據文件。 而是我想使用單個curl請求,該請求中嵌入了數據。 就像是:

curl -D- -u fred:fred -X POST --"**PASS ALL MY DATA HERE**" -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/

我知道這會使事情變得混亂,但這就是我想要的方式。 您能建議以上是否可行。

您可以使用here文檔嗎?

curl -D- -u fred:fred -X POST -d - -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/ <<EOF
{
"fields": {
  "project":
  { 
    "key": "TEST"
  },
  "summary": "REST ye merry gentlemen.",
  "description": "Creating of an issue using project keys and issue type names using the REST API",
  "issuetype": {
  "name": "Bug"
  }}}
EOF

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM