Piping a cURL command, I can get the macro variable &array to resolve but I need to make the (-d ID) a macro variable and cannot get it to work.
SAS 9.4.4
This works:
%LET array = 192.160.1.10
filename curl5 pipe %TSLIT(curl -L --location-trusted -sk https://&array.:4443/object /info?include_bucket_detail=true -d '{ "id" : ["tst-01"] }' -b /apps/ITNSM/ecs/cookie/Kookie_&array -H "Content-Type: application/json" -H "Accept: application/json") ;
Sample of what I need to get working.
This does not work: I need to have the &ID resolve the macro variable. I have tried many variation of using %str/%quote/%bquote but I do not have a good understanding of making this successful.
%LET array = 192.160.1.10
%LET ID= tst-01
filename curl5 pipe %TSLIT(curl -L --location-trusted -sk https://&array.:4443/ object /info?include_bucket_detail=true true -d '{ "id" : ["&ID"] }' -b /apps/ITNSM/ecs/cookie/Kookie_&array -H "Content-Type: application/json" -H "Accept: application/json") ;
Here is the syntax for the working cURL command under Linux: (Cookie collection is missing), The -d with single and double quotes is the requirement that is giving me trouble.
curl "https:// 192.160.1.10:4443/object/ object /info?include_bucket_detail=true true" -d '{"id" : ["tst-01"] }' \
-b /cookie/Kookie_192.160.1.10 -k -v \
-H "Content-Type: application/json" \
-H "accept: application/json"
Assuming you have added semicolons ending your %LET statements ...
Take this part:
'{ "id" : ["&ID"] }'
Replace it with:
%unquote(%str(%'{ "id" : ["&ID"] }%' ))
%STR will temporarily remove the impact of the quotes (which have been suppressing resolution of &ID), and then %UNQUOTE will restore those quotes after resolution has taken place.
Assuming you have added semicolons ending your %LET statements ...
Take this part:
'{ "id" : ["&ID"] }'
Replace it with:
%unquote(%str(%'{ "id" : ["&ID"] }%' ))
%STR will temporarily remove the impact of the quotes (which have been suppressing resolution of &ID), and then %UNQUOTE will restore those quotes after resolution has taken place.
Your solution works!...thanks for your help. I think I have a better understanding of how you used the combination of %str and %unquote to get the macro variable to resolve.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.