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

I'm need to connect to Oracle Cloud Services using a REST API and extract data into a data set.

Does anyone have a code example for this?

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Hi @BillSut - I see you asked this question in another board, but ran into a dead end -- maybe due to your org proxy.  PROC HTTP supports PROXY* options that you can use to punch through that -- you might need to get the proper settings from your IT.  I recommend you use this standalone test first to make sure things are working.

 

In using any REST service with PROC HTTP, I often work backwards by starting with API doc that offers examples in cURL.  You can find some of these for Oracle Cloud Services here (If I have done my Google searching correctly).

 

Beginning with this example:

 

 

 curl 
     -u service_cloud_user -X GET 
     -H "OSvC-CREST-Application-Context:Retrieve all incidents" 
     https://mysite.example.com/services/rest/connect/v1.4/incidents 

The PROC HTTP version would look like:

 

 

 

filename resp "path-to-json-response-to-create";

proc http
 method="GET"
 url="https://mysite.example.com/services/rest/connect/v1.4/incidents"
 out=resp
 webusername='service_cloud_user'
 webpassword='your-password'
 /* proxy options if needed */
 /* proxyhost='host' proxyport=8080 */
;
 headers
  "OSvC-CREST-Application-Context"="Retrieve all incidents";
run;

 

The result would be a JSON response in the file you specify.  You can then use LIBNAME JSON to parse this as data.

 

I think it's likely that you won't authenticate with user/password though, and that instead you'll use an auth token.  That's pretty standard these days.  I see Oracle Cloud Services supports a variety of different schemes.  I have several examples of using OAuth2-supported services, including Microsoft Office 365 and Google.

 

 

 

 

 

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

View solution in original post

5 REPLIES 5
Ksharp
Super User

You could try 

PROC HTTP

+

LIBNAME 's  JSON engine.

 

@ChrisHemedinger  wrote a couple of blogs about it.

https://blogs.sas.com/

BillSut
Calcite | Level 5

Thank you for the response.  That is what I'm trying to use but I can't find any examples with a user name and password.  These are required for the API that I'm required to use.

ChrisHemedinger
Community Manager

Hi @BillSut - I see you asked this question in another board, but ran into a dead end -- maybe due to your org proxy.  PROC HTTP supports PROXY* options that you can use to punch through that -- you might need to get the proper settings from your IT.  I recommend you use this standalone test first to make sure things are working.

 

In using any REST service with PROC HTTP, I often work backwards by starting with API doc that offers examples in cURL.  You can find some of these for Oracle Cloud Services here (If I have done my Google searching correctly).

 

Beginning with this example:

 

 

 curl 
     -u service_cloud_user -X GET 
     -H "OSvC-CREST-Application-Context:Retrieve all incidents" 
     https://mysite.example.com/services/rest/connect/v1.4/incidents 

The PROC HTTP version would look like:

 

 

 

filename resp "path-to-json-response-to-create";

proc http
 method="GET"
 url="https://mysite.example.com/services/rest/connect/v1.4/incidents"
 out=resp
 webusername='service_cloud_user'
 webpassword='your-password'
 /* proxy options if needed */
 /* proxyhost='host' proxyport=8080 */
;
 headers
  "OSvC-CREST-Application-Context"="Retrieve all incidents";
run;

 

The result would be a JSON response in the file you specify.  You can then use LIBNAME JSON to parse this as data.

 

I think it's likely that you won't authenticate with user/password though, and that instead you'll use an auth token.  That's pretty standard these days.  I see Oracle Cloud Services supports a variety of different schemes.  I have several examples of using OAuth2-supported services, including Microsoft Office 365 and Google.

 

 

 

 

 

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
BillSut
Calcite | Level 5

Thanks Chris.  My Proc HTTP that I've written looks like yours except the header part.  It's not working though.  I'm new to SAS so this is way over my head.  Thanks for your input.

ChrisHemedinger
Community Manager

Sometimes I use Postman (free tool for testing/building REST API calls) to build a prototype of the API calls I want -- easier to test and see results outside of SAS.  Once that's working, it's easy to transcribe into SAS code.

 

Chris

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2778 views
  • 2 likes
  • 3 in conversation