Project

General

Profile

Submitting data from a third-party study » History » Version 3

Tom Clegg, 04/07/2016 07:17 PM

1 1 Tom Clegg
h1. Submitting data from a third-party study
2
3
As a third-party study (aka third-party collection event), you can add data to a participant's public profile using an HTTP POST request.
4
5
<pre>
6
POST https://tapestry.example.org/third_party/add_dataset
7
</pre>
8
9
There are three mandatory form fields:
10
* @api_key@ is a unique identifier assigned to your study by Tapestry. It is shown on the "view/edit collection event" page.
11
* @participant_id@ is a unique identifier for the participant whose data is being contributed. It is sent to your third-party web site as @participant_id@ when the participant first signs up for your study.
12
* @data_sources_tsv@ is TSV data, where each line looks like
13
* <pre>
14
md5_hex <TAB> file_size_decimal <TAB> url [<CR>] <LF>
15
</pre>
16
17
Tapestry will download the data files from the URLs provided in the TSV data. The files will be added to the participant's profile only if _all_ files are downloaded successfully and the content matches the provided MD5 and file size.
18
19
Example:
20
* <pre>
21
(
22
tmpfile=$(mktemp)
23
printf 'c5b5b2fa19bd66ff23211d9f844e0131\t36868\thttps://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js\n' >"$tmpfile"
24 2 Tom Clegg
curl -X POST \
25 1 Tom Clegg
  --form api_key=9/d5b032dbea658e5289d311a1cdd4a7cba86fae0d \
26
  --form participant_code=85551af2bbc451e66344f27a2cf471994aed64f5 \
27
  --form data_sources_tsv=\<"$tmpfile" \
28
  https://my.pgp-hms.org/third_party/add_dataset
29
echo
30
rm "$tmpfile"
31 2 Tom Clegg
)
32 1 Tom Clegg
</pre>
33
34 3 Tom Clegg
Example response:
35 1 Tom Clegg
* <pre>
36 2 Tom Clegg
HTTP/1.1 200 OK
37
38 1 Tom Clegg
{"success":true}
39
</pre>
40
41
If any of the form values are invalid or improperly formatted, the HTTP response will have status 4xx and a JSON body with error details. Example:
42
* <pre>
43 2 Tom Clegg
HTTP/1.1 400 Bad Request
44
45 1 Tom Clegg
{"errors":["invalid api_key parameter"]}
46
</pre>