First time working with API and cURL commands in SAS so please bear with me. I’m trying to iterate through several datasets that have at most 150 records. The API I’m working with can only ingest 150 records at a time. I’m working with 248 test records which yields 2 datasets: CCN_1_20240805
and CCN_2_20240805
.
In the below, I’ve confirmed that :CCN_count
evaluates to 2
so the loop will execute two times.
I’ve written the following macro:
macro API_calls;
proc sql noprint;
select count(*) into :CCN_count from datasets
;quit;
%do k = 1 %to &CCN_count;
x curl -X POST '[HTTPS URL]'
--header "Authorization: Bearer &access_token."
--header 'Content_type: application/json'
--data CCN_&k._&tday.
--output test.txt;
%end;
%mend;
%API_calls;
The macro seems to run fine with no errors but when I look at the output test.txt
, I see the following error:
I basically want to be sure that the macro is executing as expected through the 2 datasets but it’s an API issue. I’m getting the token from another part of the code and putting it into the &access_token.
variable which I have also confirmed is carrying the correct token generated.
Like I said above, first time working with API calls and loops in SAS to an extent.
I appreciate the feedback.