0

I am trying to send a curl request a below,I want to send a multine value for the field "comment": as "comment": "line1 \n line2 \n line3" and it throws an error,how do I send a multine string to this field?

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)
Ritz
  • 1,193
  • 6
  • 15
  • 26
  • It looks like you may need to escape your `\n` within the postman script. – Stavr00 Apr 03 '19 at 18:31
  • Possible duplicate of [Multiline strings in JSON](https://stackoverflow.com/questions/2392766/multiline-strings-in-json) – Stavr00 Apr 03 '19 at 18:32

0 Answers0