I've researched for awhile, coming across several posts and SAS User Group presentations/papers on how to use SAS to call the REDCap API. However, all my attempts result in the same outcome.
filename my_in "C:\...api_parameters.txt";
filename my_out "C:\...api_redcap_data.csv";
filename status "C:\redcap_status.txt";
%let mytoken = tokenforredcapprojectwithnoquotes;
data _null_ ;
file my_in ;
put "%NRStr(token=)&mytoken%NRStr(&content=record&type=flat&format=csv)&";
run;
proc http
in=my_in
out= my_out
headerout = status
url ="https://redcap.institution.edu/api/"
method="post";
run;
The API parameters file is populated with this: token=tokenfromletstatement&content=record&type=flat&format=csv&
The status and data files are not populated.
Here is the error message:
ERROR: An exception has been encountered.
Please contact technical support and provide them with the following traceback information:
The SAS task name is [HTTP (2)]
ERROR: Read Access Violation HTTP (2)
Exception occurred at (02467E08)
Task Traceback
Address Frame (DBGHELP API Version 4.0 rev 5)
0000000002467E08 000000000BB2E730 tkmk:tkBoot+0x460C8
0000000002467F41 000000000BB2E7B0 tkmk:tkBoot+0x46201
00000000024697A6 000000000BB2E800 tkmk:tkBoot+0x47A66
000000000245442B 000000000BB2E870 tkmk:tkBoot+0x326EB
000000000331FA3E 000000000BB2E878 sashost:Main+0xA7F1E
000000000904E6F8 000000000BB2E8F8 tkhttp:tkextver+0x318
0000000008FCD741 000000000BB2F290 tkhttp:tkhttp+0xC741
0000000008FC6CEC 000000000BB2F390 tkhttp:tkhttp+0x5CEC
3 The SAS System 13:38 Friday, October 25, 2019
0000000008D95020 000000000BB2F398 sashttp:tkvercn1+0x3FE0
0000000008D91B20 000000000BB2F9E0 sashttp:tkvercn1+0xAE0
000000000483C477 000000000BB2F9E8 sasxshel:tkvercn1+0x4B437
0000000008D98622 000000000BB2FB00 sashttp:tkvercn1+0x75E2
0000000008D9115A 000000000BB2FBF0 sashttp:tkvercn1+0x11A
0000000003288A2B 000000000BB2FF20 sashost:Main+0x10F0B
000000000328E66D 000000000BB2FF50 sashost:Main+0x16B4D
00007FFED8BC3DC4 000000000BB2FF58 KERNEL32:BaseThreadInitThunk+0x14
00007FFED9273691 000000000BB2FF88 ntdll:RtlUserThreadStart+0x21
This is driving me crazy on why it's not working. Any help would be appreciated!
redCap has changed the api call.
You need this.
&content=record&format=csv&type=flat&rawOrLabel=raw&rawOrLabelHeaders=raw&exportCheckboxLabel=false&exportSurveyFields=false&exportDataAccessGroups=false&returnFormat=csv
I sugges you use the api playground in RedCap to generate your api call or read the documentation.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.