DATA Step, Macro, Functions and more

USE PROC HTTP to get data from API in XML format

Reply
Occasional Contributor
Posts: 5

USE PROC HTTP to get data from API in XML format

Hi All,

 

I am trying to get data in XML format from an API.  But the data I get form this API is always in JSON format.

 

I confirmed with the API's developers that it can return data in both JSON and XML depending on the request

 

Here is the code I am using:

FILENAME QAOS "/haexample/Example_Dir/Example.xml";

 

PROC HTTP

URL = "http://example.cnn.com/api/Something?format=xml"

OUT = QAOS

METHOD= 'GET'

;

RUN;

 

What am I missing here? Please help.

 

Regards,

Ahmed

 

 

Respected Advisor
Posts: 4,173

Re: USE PROC HTTP to get data from API in XML format

@aomy82

Get from your API developers a working sample get request (the URL) where they confirm that you get an XML back.

Super User
Posts: 19,861

Re: USE PROC HTTP to get data from API in XML format

Most of the time you can take the API call, post it in a browser URL bar and get the response. Make sure that works first and then verify that PROC HTTP works. FYI - I used it last week so it definitely works as intended. 

 

Another check, make sure your version of SAS supports what you're trying to do but I think PROC HTTP is pretty old. This is unlikely...but if you're not sure post your SAS version (i.e. 9.4 TS1M4)

Ask a Question
Discussion stats
  • 2 replies
  • 84 views
  • 0 likes
  • 3 in conversation