Submitting data from a third-party study » History » Version 4
Tom Clegg, 04/07/2016 07:20 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 | 4 | Tom Clegg | ( printf 'c5b5b2fa19bd66ff23211d9f844e0131\t36868\thttps://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js\n' |
24 | printf '2f624089c65f12185e79925bc5a7fc42\t121260\thttps://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css\n' |
||
25 | ) >"$tmpfile" |
||
26 | 2 | Tom Clegg | curl -X POST \ |
27 | 1 | Tom Clegg | --form api_key=9/d5b032dbea658e5289d311a1cdd4a7cba86fae0d \ |
28 | --form participant_code=85551af2bbc451e66344f27a2cf471994aed64f5 \ |
||
29 | --form data_sources_tsv=\<"$tmpfile" \ |
||
30 | https://my.pgp-hms.org/third_party/add_dataset |
||
31 | echo |
||
32 | rm "$tmpfile" |
||
33 | 2 | Tom Clegg | ) |
34 | 1 | Tom Clegg | </pre> |
35 | |||
36 | 3 | Tom Clegg | Example response: |
37 | 1 | Tom Clegg | * <pre> |
38 | 2 | Tom Clegg | HTTP/1.1 200 OK |
39 | |||
40 | 1 | Tom Clegg | {"success":true} |
41 | </pre> |
||
42 | |||
43 | 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: |
||
44 | * <pre> |
||
45 | 2 | Tom Clegg | HTTP/1.1 400 Bad Request |
46 | |||
47 | 1 | Tom Clegg | {"errors":["invalid api_key parameter"]} |
48 | </pre> |