Here is the final, elegant solution that Chris did for me. It works like a charm.
filename resp temp;
/* must include content-type/CT= option */
proc http
url="https://serviceaddress/oauth/access_token"
in='grant_type=client_credentials&client_id=XXXXXXXX&client_secret=YYYYYYYY'
ct="application/x-www-form-urlencoded"
out=resp
method='POST'
;
run;
%put &=SYS_PROCHTTP_STATUS_CODE;
data _null_;
rc=jsonpp('resp','log');
run;
libname auth json fileref=resp;
data _null_;
set auth.root;
call symputx('token',access_token);
run;
%put &=token;
filename bldgs temp;
proc http
/* increase the number of records coming back to 1000*/
url="https://serviceaddress/api/buildings?number=1000"
method='GET'
ct='application/json'
out=bldgs;
headers "Authorization" = "Bearer &token.";
;
run;
%put &=SYS_PROCHTTP_STATUS_CODE;
libname bldg json fileref=bldgs;
data bldgs;
set bldg.data;
finYear = input(financialYearStart,yymmdd10.);
format finYear date9.;
run;
proc means data=bldgs;
var managementFee;
class finYear;
format finYear year.;
run;
This API implementation has been quite unforgiving, meaning that everything in the code had to be just right for it to work. Moreover, the error messages were not helpful, it would send the generic 500 server error for every wrong attempt.
Many thanks for your help Chris!
... View more