如何将多行字符串发送到curl字段?

时间:2019-04-03 18:23:47

标签: curl postman

我正在尝试向以下发送一个curl请求,我想为"comment":的字段"comment": "line1 \n line2 \n line3"发送一个multine值,这会引发错误,我该如何向其中发送multine字符串场?

from subprocess import Popen, PIPE, call

def runCmd(cmd):
  print "Running command %s"%cmd
  proc = Popen(cmd , shell=True, stdin=PIPE,stdout=PIPE, stderr=PIPE)
  (output, error) = proc.communicate()
  if output:
    print "%s"%output
  if error:
    print '%s'%error
  return output.strip(),error.strip()


curl_command = """curl -X POST \
  https://team-builds-staging-6x3isq.usspk02.server.company.com/api/external/builds \
  -H 'API-KEY: xxxxx' \
  -H 'Accept: application/javascript' \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: xxxxx' \
  -H 'cache-control: no-cache' \
  -d '{
  "test_build": {
    "team_name": "tech",
    "tracking_radar_id":"1234567",
    "milestone_name": "milestone",
    "name": "tech Test build 4/3 - safe to delete",
    "version": "1.x",
    "submission_planned_at": "2019-04-04",
    "comment": "line1 line2 line3",
    "build_radars": "line1 line2",
    "tools_id": "https://tools.company.com/ui/containers/10338212",
    "build_tests": "QL, Hotspot, Stability Rack, IOT, Roaming, AWDL-Functional, AWDL-Performance, Performance",
    "sdk_used": "milestone17A428d",
    "dependencies": "",
    "unit_tests": "",
    "hw": "",
    "notification": "username@company.com",
    "note":"Additional notes
  }
}'"""

(output,error)=runCmd(curl_command)

0 个答案:

没有答案