<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PROC HTTP Qualtrics.com in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854705#M42037</link>
    <description>&lt;P&gt;I have carry out other tests and here's my last script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* 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'= &amp;amp;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,"&amp;amp;Partial_Survey_Name.",'i') ge 1 then call symputx('SurveyID',id,'g');
run; 
%mend GetSurveyID;
%GetSurveyID(Morgex);
%put &amp;amp;=SurveyID;

/* We have put SurveyID in the macro variable, &amp;amp;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/&amp;amp;SurveyID./export-responses/"
method= "POST"
in='{"format" : "csv"}'
out=rsp;
 headers   
   'x-api-token'= &amp;amp;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 &amp;amp;=ProgressID &amp;amp;=RequestID;

/* GET REPONSE EXPORT PROGRESS */
options set=SSLREQCERT="allow";
filename progr temp;
proc http
url="https://ca1.qualtrics.com/API/v3/surveys/&amp;amp;surveyId./export-responses/&amp;amp;ProgressID."
method= "GET"
out=progr;
 headers   
   'x-api-token'= &amp;amp;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 &amp;amp;=FileID.;

/*Get Response Export File*/

options set=SSLREQCERT="allow";
filename expfile '/.../test3.txt';
proc http
url="https://ca1.qualtrics.com/API/v3/surveys/&amp;amp;surveyId./export-responses/&amp;amp;FileID./file"
method= "GET"
out=expfile;
 headers   
   'x-api-token'= &amp;amp;Api_Token.
   'Content-Type'='application/json';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This script works but when I look into test3.txt here's what I see below .&amp;nbsp; Any idea how to solve that issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PK&amp;#3;&amp;#4;&amp;#20;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jan 2023 21:28:34 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2023-01-19T21:28:34Z</dc:date>
    <item>
      <title>PROC HTTP Qualtrics.com</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854658#M42032</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am trying to convert this&amp;nbsp;&lt;/P&gt;
&lt;DIV class="sl-flex"&gt;
&lt;DIV class="sl-flex-1 sl-break-all"&gt;&lt;SPAN class="token function"&gt;curl&lt;/SPAN&gt;&lt;SPAN class="token plain"&gt; --request GET &lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="sl-flex"&gt;
&lt;DIV class="sl-flex-1 sl-break-all"&gt;&lt;SPAN class="token plain"&gt; --url &lt;A href="https://yul1.qualtrics.com/API/v3/surveys/surveyId/export-responses/exportProgressId" target="_blank"&gt;https://yul1.qualtrics.com/API/v3/surveys/surveyId/export-responses/exportProgressId&lt;/A&gt; &lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="sl-flex"&gt;
&lt;DIV class="sl-flex-1 sl-break-all"&gt;&lt;SPAN class="token plain"&gt; --header &lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'Content-Type: application/json'&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="sl-flex"&gt;
&lt;DIV class="sl-flex-1 sl-break-all"&gt;&lt;SPAN class="token plain"&gt; --header &lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'X-API-TOKEN: '&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="sl-flex-1 sl-break-all"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sl-flex-1 sl-break-all"&gt;&lt;SPAN class="token string"&gt;into a SAS Code (see the code below) in order to obtain the fileid.&amp;nbsp; However, I am getting an 404 error which means I think that the URL is not good.&amp;nbsp; HouF!&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="sl-flex-1 sl-break-all"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sl-flex-1 sl-break-all"&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* 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"" : ""&amp;amp;ProgressID"",""surveyId"" : ""&amp;amp;SurveyID""}"
out=progr;
 headers   
   'x-api-token'= &amp;amp;Api_Token.
   'Content-Type'='application/json';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV class="sl-flex-1 sl-break-all"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sl-flex-1 sl-break-all"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 19 Jan 2023 19:06:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854658#M42032</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-01-19T19:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP Qualtrics.com</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854676#M42033</link>
      <description>&lt;P&gt;The cURL and PROC HTTP URL should be the same here.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;URL="https://yul1.qualtrics.com/API/v3/surveys/surveyId/export-responses/exportProgressId"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Only URL parameters (set off by ? and &amp;amp;) would transcribe to the IN= option the way that you tried.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 19:38:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854676#M42033</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-01-19T19:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP Qualtrics.com</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854681#M42034</link>
      <description>&lt;P&gt;Hello Chris,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have started this project as follow:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* 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'= &amp;amp;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,"&amp;amp;Partial_Survey_Name.",'i') ge 1 then call symputx('SurveyID',id,'g');
run;
%mend GetSurveyID;
%GetSurveyID(Morgex);
%put &amp;amp;=SurveyID;&lt;BR /&gt;&lt;BR /&gt;and it works&lt;BR /&gt;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;This script below is working:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options set=SSLREQCERT="allow";
filename rsp temp;
proc http
url="https://ca1.qualtrics.com/API/v3/responseexports/"
method= "POST"
in="{""format"" : ""csv"",""surveyId"" : ""&amp;amp;SurveyID""}"
out=rsp;
 headers   
   'x-api-token'= &amp;amp;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;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is there a way to find what's could be the good url for the reponse export progress&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 19:50:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854681#M42034</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-01-19T19:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP Qualtrics.com</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854690#M42035</link>
      <description>&lt;P&gt;I'm not an expert on Qualtrics API, but you can look at the entire JSON response with the JSONPP function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data _null_;
 rc=jsonpp('rsp','log');
run;&lt;/LI-CODE&gt;
&lt;P&gt;That might reveal a field that shows the status or progress URI, which you could then use in another call.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 20:00:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854690#M42035</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-01-19T20:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP Qualtrics.com</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854694#M42036</link>
      <description>&lt;P&gt;How this function works if I want to get the json reponse of qualtric.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please provide an example of SAS code?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 20:09:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854694#M42036</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-01-19T20:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP Qualtrics.com</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854705#M42037</link>
      <description>&lt;P&gt;I have carry out other tests and here's my last script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* 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'= &amp;amp;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,"&amp;amp;Partial_Survey_Name.",'i') ge 1 then call symputx('SurveyID',id,'g');
run; 
%mend GetSurveyID;
%GetSurveyID(Morgex);
%put &amp;amp;=SurveyID;

/* We have put SurveyID in the macro variable, &amp;amp;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/&amp;amp;SurveyID./export-responses/"
method= "POST"
in='{"format" : "csv"}'
out=rsp;
 headers   
   'x-api-token'= &amp;amp;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 &amp;amp;=ProgressID &amp;amp;=RequestID;

/* GET REPONSE EXPORT PROGRESS */
options set=SSLREQCERT="allow";
filename progr temp;
proc http
url="https://ca1.qualtrics.com/API/v3/surveys/&amp;amp;surveyId./export-responses/&amp;amp;ProgressID."
method= "GET"
out=progr;
 headers   
   'x-api-token'= &amp;amp;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 &amp;amp;=FileID.;

/*Get Response Export File*/

options set=SSLREQCERT="allow";
filename expfile '/.../test3.txt';
proc http
url="https://ca1.qualtrics.com/API/v3/surveys/&amp;amp;surveyId./export-responses/&amp;amp;FileID./file"
method= "GET"
out=expfile;
 headers   
   'x-api-token'= &amp;amp;Api_Token.
   'Content-Type'='application/json';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This script works but when I look into test3.txt here's what I see below .&amp;nbsp; Any idea how to solve that issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PK&amp;#3;&amp;#4;&amp;#20;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 21:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-HTTP-Qualtrics-com/m-p/854705#M42037</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-01-19T21:28:34Z</dc:date>
    </item>
  </channel>
</rss>

