first i want to say i already readed similar topics and even thinked i found solution already, but now i get really confused because finally it appear sometimes this solution works but sometimes for unknown me reason it give fail. So, i need send to API this:
curl -X POST https://example.com/ppn -d 'param_one=87,a1b2c3d4&format=json¶m_two=23,12,14¶m_three=param_four¶m_five=G&value=Password.123'
It have correct syntax and if i'm sending it from command line it allways works. now what i need is use Password.123 as variable what is being taken from config.json. Here is how i realized it already with help of other similar topic by puting variable $pass1 in double quotes "'"$pass1"'".
#!/bin/bash
pass1=$( jq -r '.[] | .pass1' config.json; )
curl -X POST https://example.com/ppn -d 'param_one=87,a1b2c3d4&format=json¶m_two=23,12,14¶m_three=param_four¶m_five=G&value="'"$pass1"'"'
but problem is, may be i'm loosing my mind already because spend too much hours at PC, but i swear it worked few times, but now it's not work at all. i guess sometimes it works, but sometimes not. mostly not and i have no idea why is that because it's being sent to public API service i have no way see any error details.
also this line with " instead of ' there not gonna work at all:
curl -X POST https://example.com/ppn -d "param_one=87,a1b2c3d4&format=json¶m_two=23,12,14¶m_three=param_four¶m_five=G&value='$pass1'"
and not this:
curl -X POST https://example.com/ppn -d 'param_one=87,a1b2c3d4&format=json¶m_two=23,12,14¶m_three=param_four¶m_five=G&value="$pass1"'
Or anything else i already tried. How can i workaround this? To there be sent pure command like in 1st example, by using bash script but still used variable $pass1 from config.json file?
thank you very much
You shouldn't have literal quotes after value= in the URL.
Your second attempt was close except for the explicit ' characters.
curl -X POST https://example.com/ppn -d "param_one=87,a1b2c3d4&format=json¶m_two=23,12,14¶m_three=param_four¶m_five=G&value=$pass1"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With