Luke Stevens, Murdoch Children's Research Institute https://www.mcri.edu.au
https://github.com/lsgs/redcap-redcap-rest
An external module enabling REDCap to send outbound API calls when saving data entry or survey forms and specified conditions are met. This can facilitate copying of data from your REDCap project to another application via its API, or to another REDCap project in either the same or a different instance of REDCap.
v1.4.0 introduces the facility for configuring sensitive configuration such as API or Autorization tokens at system level rather than hard-coding tokens into project module configuration. Use the placeholder [token-ref:someref]
in place of your sensitive configuration value, and have your system administrator configure someref
at system level. Tokens configured this way are also masked in logging.
Multiple outbound API messages can be configured via the External Modules Configure dialog.
Enabled?
Trigger form(s)
Trigger condition
Destination URL
https://consentmgt.ourplace.org/api/record/[record_id]
Payload
{
"consent": [consent],
"consent_date": "[consentdt]"
}
Content Type
Additional Headers
cURL Options
Capture of Return Data
API response data can be captured into fields within the same event as the triggering form.
Result Field
Response HTTP Code
Map JSON Response Data to Fields
Call a REDCap API endpoint to obtain the value of field [fieldtogetvaluefor]
for the record id piped in from field [recordtofind]
:
https://redcap.someplace.edu/api/
POST
token=[token-ref:my-project-123-token]&content=record&type=flat&format=json&records=[recordtofind]&fields[]=record_id&fields[]=fieldtogetvaluefor
application/x-www-form-urlencoded
(note not application/json
)Obtain published details of a clinical trial identified using its ANZCTR ID (piped into paylod using [anzctrid]
):
https://www.anzctr.org.au/WebServices/AnzctrWebservices.asmx
POST
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<AnzctrTrialDetails xmlns="http://anzctr.org.au/WebServices/AnzctrWebServices">
<ids>[anzctrid]</ids>
</AnzctrTrialDetails>
</soap12:Body>
</soap12:Envelope>
application/soap+xml; charset=utf-8
Send a payload to an API endpoint secured with Basic Auth, uncluding an encoded token as an HTTP header:
https://deep.thought.org/endpoint/
POST
{ "answer":42 }
application/json
Authorization: Basic SWYgdGhhdCdzIHRoZSBhbnN3ZXIsIHdoYXQgaXMgdGhlIHF1ZXN0aW9uPw==
or, better:Authorization: Basic [token-ref:my-basic-auth-token]
Configure sensitive configuration such as API or Autorization tokens at system level rather than hard-coding tokens into project module configuration. Use the placeholder [token-ref:someref]
in place of your sensitive configuration value, and have your system administrator configure someref
at system level. Tokens configured this way are also masked in logging.
Token Reference
[token-ref:xyz]
where xyz
matches this reference.Token Destination URL
Token Lookup Option
Token Lookup Option "Lookup": Project
Token Lookup Option "Lookup": Username
Token Lookup Option Specify