Some studies have found some useful stackexchange articles, namely an extension variable in CURL , but this answer does not seem to handle bash variables that have spaces in them correctly.
I set the variable to awk output by parsing a substring string (actually trimming to 150 characters). The line I'm trying to do POST through curl contains spaces.
When I use the following curl arguments, the POST Body variable is set to the portion of the line before the first space.
curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/GUID/SMS/Messages.xml' -d 'From=DIDfrom' -d 'To=DIDto' -d 'Body="'$smsbody'" -u SECGUID
smsbody set as:
smsbody="$(echo $HOSTNAME$ $SERVICEDESC$ in $SERVICESTATE$\: $SERVICEOUTPUT$ | awk '{print substr($0,0,150)}')"
So the only part of smsbody that is POSTED is $HOSTNAME$ (which is a string without any spaces).
What is the curl syntax that I should use to properly place the bash variable for the extension, but be taken as a single data field?
It seems pretty trivial, but I accidentally messed up the quotes without any luck. I believe that someone with the best CLI-fu can handle it in a second.
Thanks!
source share