BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
leh25
Calcite | Level 5

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"

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

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.

leh25
Calcite | Level 5

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.

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2872 views
  • 1 like
  • 2 in conversation