Closed lmdamato closed 1 year ago
Found a solution to my own issue, thanks to a combination of two factors:
curlie
and curl
handle POST
requests. This only happens when passing data using the -d
option (but not when passing --data
!). In fact, my same curlie
command, using --data
instead of -d
, fails. This is a documented issue: https://github.com/rs/curlie/issues/11curlie
has a nice --curl
option, which prints out the curl command instead of executing it.I was able to infer that, in specific cases (like the one mentioned in 1. above), curlie
injects additional Content-Type
and Accept
headers in the request, and thanks the extra headers the request succeeded.
In my specific case, it was just a matter of adding -H 'Content-Type: application/json' -H 'Accept: application/json, */*'
to the curl
command:
curl -v -H 'Content-Type: application/json' -H 'Accept: application/json, */*' -H 'X-SLURM-USER-TOKEN: someLongToken' -H 'X-SLURM-USER-NAME: lmdamato' -X POST -d '{"job":{"environment":{"LD_LIBRARY_PATH":"/lib/:/lib64/:/usr/local/lib","PATH":"/bin:/usr/bin/:/usr/local/bin/"},"name":"my_test_hello_world_job","partition":"QT","qos":"medium"},"script":"#!/bin/bash\n/bin/hostname"}' http://myslurmhost:6820/slurm/v0.0.37/job/submit
I am trying to run a POST request in vanilla cURL, but failing at it. I can easily run it in curlie (I expect the 500):
But the exact same command in vanilla cURL won't work:
Can someone help me understand why?