curl: 400 Bad Request. The browser (or proxy) sent a request that this server could not understand

I'm getting "400 Bad Request. The browser (or proxy) sent a request that this server could not understand." for the curl command. Curl command is as below, can someone please help?

token=jfkdjfdikdjydve83hhd54rsfdghsghktwhdh87
payload_file=test_fortify_scan.zip

curl -X POST https://dnsname/api/scan \
-H "authorization: Bearer $token" \
-H 'content-type: application/json' \
-d '{"projVer": "dev", "language": "java", 
"payloadFile":"$payload_file", "emailList": "myemail@mail.com"}'

1 answer

  • answered 2018-07-12 07:43 lojza

    Looks like quotes problem. Look at Using curl POST with variables defined in bash script functions

    token="jfkdjfdikdjydve83hhd54rsfdghsghktwhdh87"
    payload_file="test_fortify_scan.zip"
    
    curl -X POST https://dnsname/api/scan \
    -H "authorization: Bearer $token" \
    -H 'content-type: application/json' \
    -d '{"projVer": "dev", "language": "java",
    "payloadFile":"'"$payload_file"'", "emailList": "myemail@mail.com"}'