- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am trying to convert this
/* GET REPONSE EXPORT PROGRESS */
options set=SSLREQCERT="allow";
filename progr temp;
proc http
url="https://ca1.qualtrics.com/API/v3/responseexports/"
method= "GET"
in="{""exportProgressId"" : ""&ProgressID"",""surveyId"" : ""&SurveyID""}"
out=progr;
headers
'x-api-token'= &Api_Token.
'Content-Type'='application/json';
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The cURL and PROC HTTP URL should be the same here.
URL="https://yul1.qualtrics.com/API/v3/surveys/surveyId/export-responses/exportProgressId"
Only URL parameters (set off by ? and &) would transcribe to the IN= option the way that you tried.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The cURL and PROC HTTP URL should be the same here.
URL="https://yul1.qualtrics.com/API/v3/surveys/surveyId/export-responses/exportProgressId"
Only URL parameters (set off by ? and &) would transcribe to the IN= option the way that you tried.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello Chris,
I have started this project as follow:
/* First Step, looking at the survey list available */
%let Api_Token='**********************************wJOJfD74l0sc1';
options set=SSLREQCERT="allow";
filename resp temp;
PROC HTTP
METHOD="GET"
URL= 'https://ca1.qualtrics.com/API/v3/surveys'
OUT=resp;
headers
'x-api-token'= &Api_Token.;
run;
/* Let the JSON engine do its thing */
libname posts JSON fileref=resp;
title "Automap of JSON data";
/* examine resulting tables/structure */
proc datasets lib=posts; quit;
proc print data=posts.alldata; run;
data Basic_survey_info (drop=ordinal_result ordinal_elements);
set posts.result_elements;
obs=ordinal_elements;
run;
/* Choosing the good survey by providing a partial name and putting the SurveyID into a macro variable*/
%macro GetSurveyID(Partial_Survey_Name);
data Basic_survey_info;
set Basic_survey_info;
if find(name,"&Partial_Survey_Name.",'i') ge 1 then call symputx('SurveyID',id,'g');
run;
%mend GetSurveyID;
%GetSurveyID(Morgex);
%put &=SurveyID;and it works
This script below is working:
options set=SSLREQCERT="allow";
filename rsp temp;
proc http
url="https://ca1.qualtrics.com/API/v3/responseexports/"
method= "POST"
in="{""format"" : ""csv"",""surveyId"" : ""&SurveyID""}"
out=rsp;
headers
'x-api-token'= &Api_Token.
'Content-Type'='application/json';
run;
/* Let the JSON engine do its thing */
libname RSP JSON fileref=rsp;
title "Automap of JSON data";
/* examine resulting tables/structure */
proc datasets lib=RSP; quit;
proc print data=RSP.alldata; run;
proc print data=RSP.meta; run;
proc print data=RSP.result; run;
Data ReponseExport;
set rsp.alldata;
if p2 = 'id' then call symputx('ProgressID',value,'g');
if p2 = 'requestId' then call symputx('RequestID',Value,'g');
run;
Is there a way to find what's could be the good url for the reponse export progress
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm not an expert on Qualtrics API, but you can look at the entire JSON response with the JSONPP function:
data _null_;
rc=jsonpp('rsp','log');
run;
That might reveal a field that shows the status or progress URI, which you could then use in another call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How this function works if I want to get the json reponse of qualtric.com
Could you please provide an example of SAS code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have carry out other tests and here's my last script.
/* First Step, looking at the survey list available */
%let Api_Token='****************************fD74l0sc1';
options set=SSLREQCERT="allow";
filename resp temp;
PROC HTTP
METHOD="GET"
URL= 'https://ca1.qualtrics.com/API/v3/surveys'
OUT=resp;
headers
'x-api-token'= &Api_Token.;
run;
/* Let the JSON engine do its thing */
libname posts JSON fileref=resp;
title "Automap of JSON data";
/* examine resulting tables/structure */
proc datasets lib=posts; quit;
proc print data=posts.alldata; run;
data Basic_survey_info (drop=ordinal_result ordinal_elements);
set posts.result_elements;
obs=ordinal_elements;
run;
/* Choosing the good survey by providing a partial name and putting the SurveyID into a macro variable*/
%macro GetSurveyID(Partial_Survey_Name);
data Basic_survey_info;
set Basic_survey_info;
if find(name,"&Partial_Survey_Name.",'i') ge 1 then call symputx('SurveyID',id,'g');
run;
%mend GetSurveyID;
%GetSurveyID(Morgex);
%put &=SurveyID;
/* We have put SurveyID in the macro variable, &SurveyID.*/
/* Create Response Export / Start Response Export */
/* In that step, we need to provide the SurveyID (see previous step)
in order to get the RequestID as well as the ProgressID */
/******************************************************************************************/
options set=SSLREQCERT="allow";
filename rsp temp;
proc http
url="https://ca1.qualtrics.com/API/v3/surveys/&SurveyID./export-responses/"
method= "POST"
in='{"format" : "csv"}'
out=rsp;
headers
'x-api-token'= &Api_Token.
'Content-Type'='application/json';
run;
/* Let the JSON engine do its thing */
libname RSP JSON fileref=rsp;
title "Automap of JSON data";
/* examine resulting tables/structure */
proc datasets lib=RSP; quit;
proc print data=RSP.alldata; run;
proc print data=RSP.meta; run;
proc print data=RSP.result; run;
Data ReponseExport;
set rsp.alldata;
if p2 = 'progressId' then call symputx('ProgressID',strip(value),'g');
if p2 = 'requestId' then call symputx('RequestID',strip(Value),'g');
run;
%put &=ProgressID &=RequestID;
/* GET REPONSE EXPORT PROGRESS */
options set=SSLREQCERT="allow";
filename progr temp;
proc http
url="https://ca1.qualtrics.com/API/v3/surveys/&surveyId./export-responses/&ProgressID."
method= "GET"
out=progr;
headers
'x-api-token'= &Api_Token.
'Content-Type'='application/json';
run;
/* Let the JSON engine do its thing */
libname progr JSON fileref=progr;
title "Automap of JSON data";
/* examine resulting tables/structure */
proc datasets lib=progr; quit;
proc print data=progr.alldata; run;
proc print data=progr.meta; run;
proc print data=progr.result; run;
Data ReponseExport;
set progr.alldata;
if p2 = 'fileId' then call symputx('FileID',strip(value),'g');
run;
%put &=FileID.;
/*Get Response Export File*/
options set=SSLREQCERT="allow";
filename expfile '/.../test3.txt';
proc http
url="https://ca1.qualtrics.com/API/v3/surveys/&surveyId./export-responses/&FileID./file"
method= "GET"
out=expfile;
headers
'x-api-token'= &Api_Token.
'Content-Type'='application/json';
run;
This script works but when I look into test3.txt here's what I see below . Any idea how to solve that issue.
PK