SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
evaleah
Obsidian | Level 7

I am making an API call that retrieves a zip file. This was working very nicely when the file was itsy-bitsy. Now it is just tiny and the resulting zip file has nothing in it. I have not changed any code, the zip now just does not contain the one file it should have. My error trap shows I am receiving a 200-ok, so it is not failing there. When I run the exact same API call via Postman it returns with contents as one would expect. What am I missing here?

 

I am attaching resp.zip which is the result I get from the Postman call and resp(1).zip which is what I am getting from the SAS code below.

 

%macro testq;
	%let rootpath=/dcri/cdm/DEV;
	%include "&rootpath/httperrorcatch.sas";
	%let base_url=https://ca1.qualtrics.com;
	%let logpath=/dcri/cdm/DEV/Qualtrics;
	filename resp zip "&logpath/resp.zip";

	proc http
		url="&base_url/API/v3/surveys/surveyID/export-responses/fildID/file"
		method="GET"
		in='{"format":"json"}'
		out=resp;
		HEADERS 
			"x-api-token"="mytoken"
			"content-type"="application/json";
	run;
	/* catch error */
	%prochttp_check_return(code=200,respFile=&logpath/restatus.txt);
%mend testq;

%testq;

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
evaleah
Obsidian | Level 7

I had MPRINT on already. Nothing there helped. BUT, I figured out the issue.

I declared the file with this statement: 

filename resp zip "&logpath/resp.zip";

The file is a zip but for some reason SAS does not pull it down when it is declared as such. I removed the "zip" keyword and it comes as expected.

View solution in original post

2 REPLIES 2
ballardw
Super User

Set option MPRINT and rerun the code.

Copy from the log the result and paste the code and all the messages into a code box opened with the </>.

 

 

evaleah
Obsidian | Level 7

I had MPRINT on already. Nothing there helped. BUT, I figured out the issue.

I declared the file with this statement: 

filename resp zip "&logpath/resp.zip";

The file is a zip but for some reason SAS does not pull it down when it is declared as such. I removed the "zip" keyword and it comes as expected.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 699 views
  • 0 likes
  • 2 in conversation