Hi there, I'm trying to translate this code into SAS code with PROC HTTP
curl --insecure -k https://server/oauth/token -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=password&username=user&password=xxxx" -u client:clientsecret"
So far, I have this SAS code
proc http url="&server_host/&server_endpoint_token"
in=jsonin
webusername="client"
webpassword="clientsecret"
CT="Content-Type=application/x-www-form-urlencoded"
out=jsonout
headerout=headout;
debug level=3;
headers "Accept"="application/json" ;
run;
The problem is that I have to accept the self-signed certificate but I don't know how to implement that in the PROC HTTP procedure.
Does someone know how to do that?
Some tweaks to the way you transcribed the cURL to PROC HTTP:
proc http url="&server_host/&server_endpoint_token"
in="%nrstr(&grant_type)=password%nrstr(&username)=user"
webusername="client"
webpassword="clientsecret"
CT="application/x-www-form-urlencoded"
out=jsonout
headerout=headout;
debug level=3;
headers "Accept"="application/json" ;
run;
If you share more about which service you're using (if it's something common), we might have a better example.
the IN= takes what you specify in cURL -d option. The webusername/webpassword takes what you specify in the -u option. CT= is shorthand for "Content-Type" so no need to include the "Content-Type=" as part of the value.
The SSLPARMS statement can help specify behavior for verifying certificates. Adding the SSLREQCERT= value may help.
Something like:
sslparms "sslreqcert"="allow";
Some tweaks to the way you transcribed the cURL to PROC HTTP:
proc http url="&server_host/&server_endpoint_token"
in="%nrstr(&grant_type)=password%nrstr(&username)=user"
webusername="client"
webpassword="clientsecret"
CT="application/x-www-form-urlencoded"
out=jsonout
headerout=headout;
debug level=3;
headers "Accept"="application/json" ;
run;
If you share more about which service you're using (if it's something common), we might have a better example.
the IN= takes what you specify in cURL -d option. The webusername/webpassword takes what you specify in the -u option. CT= is shorthand for "Content-Type" so no need to include the "Content-Type=" as part of the value.
The SSLPARMS statement can help specify behavior for verifying certificates. Adding the SSLREQCERT= value may help.
Something like:
sslparms "sslreqcert"="allow";
I'm using your code but it seems like there is a problem with the credentials, this is the way I created the jsonin file, I already correct the PROC HTTP statement as well
filename jsonin temp lrecl=32760;
filename jsonout temp lrecl=32760;
filename headout temp lrecl=32760;
%let string= 'grant_type=password&username=client&password=xxxx'; data _null_; call symputx('FLEN', length(&string)); run; data _null_; file jsonin recfm=F lrecl=&FLEN; put &string; run; proc http url="&server_host/&server_endpoint_token" in=jsonin webusername="client" webpassword="cleintsecret" CT="application/x-www-form-urlencoded" out=jsonout headerout=headout; debug level=3; headers "Accept"="application/json" ; run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.