|
I have been trying to import (upload) data into a REDCap (www.project-redcap.org) database, meaning a MySQL database.
I have been able to export (download) both data and metadata. The attempts at importing result in a 403 return code. I POST using the HTTP procedure in V9.2, but have changed the URL for this post:
200 FileName Upload "C:\raw.csv" ;
201 FileName HeaderIn Temp ;
202 FileName HeaderO Temp ;
203
204 Data _null_ ;
205 File HeaderIn ;
206 Put "%NRStr(content=record&type=flat&format=csv&token=)&Token.%NRStr(&data=Upload&overwriteBehavior=normal)" ;
207 Run ;
NOTE: The file HEADERIN is:
Filename=C:\DOCUME~1\kviel\LOCALS~1\Temp\SAS Temporary Files\_TD5052\#LN00020,
RECFM=V,LRECL=256,File Size (bytes)=0,
Last Modified=22Jul2011:11:33:33,
Create Time=22Jul2011:11:33:33
NOTE: 1 record was written to the file HEADERIN.
The minimum record length was 111.
The maximum record length was 111.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
208
209 Proc HTTP In = Upload
210 HeaderIn = HeaderIn
211 HeaderOut = HeaderO
212 URL = "https://www.XXX/redcap/api/"
213 Method = "POST"
214 ;
215 Run ;
NOTE: PROCEDURE HTTP used (Total process time):
real time 0.26 seconds
cpu time 0.03 seconds
NOTE: The SAS System stopped processing this step because of errors.
216
217
218 Data _null_ ;
219 Infile HeaderO ;
220 Input ;
221 Put _Infile_ ;
222 Run ;
NOTE: The infile HEADERO is:
Filename=C:\DOCUME~1\kviel\LOCALS~1\Temp\SAS Temporary Files\_TD5052\#LN00021,
RECFM=V,LRECL=256,File Size (bytes)=362,
Last Modified=22Jul2011:11:33:33,
Create Time=22Jul2011:11:33:33
X-Powered-By:PHP/5.3.3
Connection:Keep-Alive
Expires:0
cache-control:no-store, no-cache, must-revalidate
Date:Fri, 22 Jul 2011 15:33:32 GMT
Keep-Alive:timeout=100, max=100
HTTP/1.1 403 Forbidden
Pragma:no-cache
Server:Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/0.9.7a mod_bwlimited/1.4
Content-Type:text/html; charset=utf-8
Transfer-Encoding:chunked
NOTE: 11 records were read from the infile HEADERO.
The minimum record length was 9.
The maximum record length was 75.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: java.io.IOException: Server returned HTTP response code: 403 for URL: https://www.XXXX/redcap/api/
I think the PHP file maybe:
<?php
# the class that performs the API call
require_once('RestCallRequest.php');
# OPTION 1: place your data here in between <<<DATA and DATA, formatted according to the type and format you've set below
$YOUR_DATA = <<<DATA
study_id,age,sex
"test_001",31,0
"test_002",27,1
DATA;
# or OPTION 2: fill the variable with data from a file
//$YOUR_DATA = file_get_contents(YOUR_FILE)
# an array containing all the elements that must be submitted to the API
$data = array('content' => 'record', 'type' => 'eav', 'format' => 'csv', 'token' => 'YOUR_TOKEN',
'data' => $YOUR_DATA);
# create a new API request object
$request = new RestCallRequest("API_URL", 'POST', $data);
# initiate the API request
$request->execute();
# the following line will print out the entire HTTP request object
# good for testing purposes to see what is sent back by the API and for debugging
//echo '<pre>' . print_r($request, true) . '</pre>';
# print the output from the API
echo $request->getResponseBody();
Can anyone suggest why I might be getting a 403 return code?
Thank you,
Kevin
Kevin Viel, PhD
Senior Research Statistician
Patient Safety & Quality
International College of Robotic Surgery
Saint Joseph's Translational Research Institute
Saint Joseph's Hospital
5671 Peachtree Dunwoody Road, NE, Suite 330
Atlanta, GA 30342
(678) 843-6076: Direct Phone
(678) 843-6153: Facsimile
(404) 558-1364: Mobile
kviel@sjha.org
Confidentiality Notice:
This e-mail, including any attachments is the
property of Catholic Health East and is intended
for the sole use of the intended recipient(s).
It may contain information that is privileged and
confidential. Any unauthorized review, use,
disclosure, or distribution is prohibited. If you are
not the intended recipient, please delete this message, and
reply to the sender regarding the error in a separate email.
|