diff --git a/README.md b/README.md
index dbefcd3..215e4bf 100644
--- a/README.md
+++ b/README.md
@@ -80,21 +80,21 @@ __Install directly in Package Manager Console or Command Line Interface__
```C#
Package Manager
-Install-Package RedcapAPI -Version 1.3.0
+Install-Package RedcapAPI -Version 1.3.1
```
```C#
.NET CLI
-dotnet add package RedcapAPI --version 1.3.0
+dotnet add package RedcapAPI --version 1.3.1
```
```C#
Paket CLI
-paket add RedcapAPI --version 1.3.0
+paket add RedcapAPI --version 1.3.1
```
diff --git a/RedcapApi/Api/RedcapApi.cs b/RedcapApi/Api/RedcapApi.cs
index 7c25a74..9656055 100644
--- a/RedcapApi/Api/RedcapApi.cs
+++ b/RedcapApi/Api/RedcapApi.cs
@@ -46,6 +46,10 @@ public class RedcapApi : IRedcap
/// The version of redcap that the api is currently interacting with.
///
public static string Version;
+ ///
+ /// default constructor
+ ///
+ ///
public RedcapApi(string redcapApiUrl)
{
_uri = new Uri(redcapApiUrl);
@@ -69,9 +73,8 @@ public RedcapApi(string redcapApiUrl, bool useInsecureCertificates = false)
}
#region Arms
///
- /// API Version 1.0.0+ **
- /// From Redcap Version 4.7.0
- /// Export Arms
+ /// From Redcap Version 4.7.0
+ /// Export Arms
/// This method allows you to export the Arms for a project
/// NOTE: This only works for longitudinal projects.
///
@@ -79,11 +82,11 @@ public RedcapApi(string redcapApiUrl, bool useInsecureCertificates = false)
/// To use this method, you must have API Export privileges in the project.
///
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
- /// csv, json [default], xml
+ /// csv, json [default], xml
/// an array of arm numbers that you wish to pull events for (by default, all events are pulled)
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Arms for the project in the format specified(only ones with Events available)
- public async Task ExportArmsAsync(string token, ReturnFormat returnFormat = ReturnFormat.json, string[] arms = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportArmsAsync(string token, RedcapFormat format = RedcapFormat.json, string[] arms = null, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -98,7 +101,7 @@ public async Task ExportArmsAsync(string token, ReturnFormat returnForma
{
{ "token", token },
{ "content", Content.Arm.GetDisplayName() },
- { "format", returnFormat.GetDisplayName() }
+ { "format", format.GetDisplayName() }
};
// Optional
if (arms?.Length > 0)
@@ -109,7 +112,7 @@ public async Task ExportArmsAsync(string token, ReturnFormat returnForma
}
}
// defaults to 'json'
- payload.Add("returnFormat", onErrorFormat.GetDisplayName());
+ payload.Add("returnFormat", returnFormat.GetDisplayName());
// Execute send request
return await this.SendPostRequestAsync(payload, _uri);
@@ -126,9 +129,8 @@ public async Task ExportArmsAsync(string token, ReturnFormat returnForma
}
///
- /// API Version 1.0.0+ **
- /// From Redcap Version 4.7.0
- /// Export Arms
+ /// From Redcap Version 4.7.0
+ /// Export Arms
/// This method allows you to export the Arms for a project
/// NOTE: This only works for longitudinal projects.
///
@@ -137,11 +139,11 @@ public async Task ExportArmsAsync(string token, ReturnFormat returnForma
///
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// arm
- /// csv, json [default], xml
+ /// csv, json [default], xml
/// e.g. ["1","2"] an array of arm numbers that you wish to pull events for (by default, all events are pulled)
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Arms for the project in the format specified(only ones with Events available)
- public async Task ExportArmsAsync(string token, Content content, ReturnFormat returnFormat = ReturnFormat.json, string[] arms = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportArmsAsync(string token, Content content = Content.Arm, RedcapFormat format = RedcapFormat.json, string[] arms = null, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -156,7 +158,7 @@ public async Task ExportArmsAsync(string token, Content content, ReturnF
{
{ "token", token },
{ "content", content.GetDisplayName() },
- { "format", returnFormat.GetDisplayName() }
+ { "format", format.GetDisplayName() }
};
// Optional
if (arms?.Length > 0)
@@ -167,7 +169,7 @@ public async Task ExportArmsAsync(string token, Content content, ReturnF
}
}
// defaults to 'json'
- payload.Add("returnFormat", onErrorFormat.GetDisplayName());
+ payload.Add("returnFormat", returnFormat.GetDisplayName());
// Execute send request
return await this.SendPostRequestAsync(payload, _uri);
@@ -184,10 +186,9 @@ public async Task ExportArmsAsync(string token, Content content, ReturnF
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 4.7.0
+ /// From Redcap Version 4.7.0
///
- /// Import Arms
+ /// Import Arms
/// This method allows you to import Arms into a project or to rename existing Arms in a project.
/// You may use the parameter override=1 as a 'delete all + import' action in order to erase all existing Arms in the project while importing new Arms.
/// Notice: Because of the 'override' parameter's destructive nature, this method may only use override=1 for projects in Development status.
@@ -209,7 +210,7 @@ public async Task ExportArmsAsync(string token, Content content, ReturnF
///
/// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'.
/// Number of Arms imported
- public async Task ImportArmsAsync(string token, Override overrideBhavior, RedcapAction action, ReturnFormat format, List data, OnErrorFormat returnFormat = OnErrorFormat.json)
+ public async Task ImportArmsAsync(string token, Override overrideBhavior, RedcapAction action, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -243,10 +244,9 @@ public async Task ImportArmsAsync(string token, Override overrideBhav
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 4.7.0
+ /// From Redcap Version 4.7.0
///
- /// Import Arms
+ /// Import Arms
/// This method allows you to import Arms into a project or to rename existing Arms in a project.
/// You may use the parameter override=1 as a 'delete all + import' action in order to erase all existing Arms in the project while importing new Arms.
/// Notice: Because of the 'override' parameter's destructive nature, this method may only use override=1 for projects in Development status.
@@ -269,7 +269,7 @@ public async Task ImportArmsAsync(string token, Override overrideBhav
///
/// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'.
/// Number of Arms imported
- public async Task ImportArmsAsync(string token, Content content, Override overrideBhavior, RedcapAction action, ReturnFormat format, List data, OnErrorFormat returnFormat)
+ public async Task ImportArmsAsync(string token, Content content, Override overrideBhavior, RedcapAction action, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -303,10 +303,9 @@ public async Task ImportArmsAsync(string token, Content content, Over
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 4.7.0
+ /// From Redcap Version 4.7.0
///
- /// Delete Arms
+ /// Delete Arms
/// This method allows you to delete Arms from a project.
/// Notice: Because of this method's destructive nature, it is only available for use for projects in Development status. Additionally, please be aware that deleting an arm also automatically deletes all events that belong to that arm, and will also automatically delete any records/data that have been collected under that arm (this is non-reversible data loss).
/// NOTE: This only works for longitudinal projects.
@@ -327,7 +326,7 @@ public async Task DeleteArmsAsync(string token, string[] arms)
this.CheckToken(token);
if (arms.Length < 1)
{
- throw new InvalidOperationException($"No arm to delete, specify arm");
+ throw new ArgumentNullException($"No arm to delete, please specify arm");
}
var payload = new Dictionary
@@ -372,7 +371,7 @@ public async Task DeleteArmsAsync(string token, string[] arms)
/// delete
/// an array of arm numbers that you wish to delete
/// Number of Arms deleted
- public async Task DeleteArmsAsync(string token, Content content, RedcapAction action, string[] arms)
+ public async Task DeleteArmsAsync(string token, Content content = Content.Event, RedcapAction action = RedcapAction.Delete, string[] arms = default)
{
try
{
@@ -382,7 +381,7 @@ public async Task DeleteArmsAsync(string token, Content content, RedcapA
this.CheckToken(token);
if (arms.Length < 1)
{
- throw new InvalidOperationException($"No arm to delete, specify arm");
+ throw new ArgumentNullException($"No arm to delete, please specify arm");
}
var payload = new Dictionary
@@ -413,8 +412,7 @@ public async Task DeleteArmsAsync(string token, Content content, RedcapA
#region Data Access Groups
///
- /// POST
- /// Export DAGs
+ /// Export DAGs
/// This method allows you to export the Data Access Groups for a project
///
/// To use this method, you must have API Export privileges in the project.
@@ -423,9 +421,9 @@ public async Task DeleteArmsAsync(string token, Content content, RedcapA
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// dag
/// csv, json [default], xml
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// DAGs for the project in the format specified
- public async Task ExportDagsAsync(string token, Content content, ReturnFormat format = ReturnFormat.json, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportDagsAsync(string token, Content content = Content.Dag, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
var exportDagsResults = string.Empty;
try
@@ -439,7 +437,7 @@ public async Task ExportDagsAsync(string token, Content content, ReturnF
{ "token", token },
{ "content", content.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
exportDagsResults = await this.SendPostRequestAsync(payload, _uri);
return exportDagsResults;
@@ -453,7 +451,6 @@ public async Task ExportDagsAsync(string token, Content content, ReturnF
}
///
- /// POST
/// Import DAGs
/// This method allows you to import new DAGs (Data Access Groups) into a project or update the group name of any existing DAGs.
/// NOTE: DAGs can be renamed by simply changing the group name(data_access_group_name).
@@ -478,9 +475,9 @@ public async Task ExportDagsAsync(string token, Content content, ReturnF
/// "FL Site",fl_site
/// "New Site",
///
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Number of DAGs added or updated
- public async Task ImportDagsAsync(string token, Content content, RedcapAction action, ReturnFormat format, List data, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ImportDagsAsync(string token, Content content, RedcapAction action, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
var importDagsResults = string.Empty;
try
@@ -495,7 +492,7 @@ public async Task ImportDagsAsync(string token, Content content, Redc
{ "content", content.GetDisplayName() },
{ "action", action.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "data", _serializedData }
};
// Execute request
@@ -510,8 +507,7 @@ public async Task ImportDagsAsync(string token, Content content, Redc
}
///
- /// POST
- /// Delete DAGs
+ /// Delete DAGs
/// This method allows you to delete DAGs from a project.
///
/// To use this method, you must have API Import/Update privileges in the project.
@@ -556,11 +552,11 @@ public async Task DeleteDagsAsync(string token, Content content, RedcapA
return deleteDagsResult;
}
}
-
+
///
- /// From Redcap Version 11.3.1
+ /// From Redcap Version 11.3.1
///
- /// Switch DAG
+ /// Switch DAG
/// This method allows the current API user to switch (assign/reassign/unassign) their current Data Access Group assignment if they have been assigned to multiple DAGs via the DAG Switcher page in the project.
///
/// To use this method, you must have API Import/Update privileges in the project.
@@ -599,7 +595,7 @@ public async Task SwitchDagAsync(string token, RedcapDag dag, Content co
}
///
- /// Export User-DAG Assignments
+ /// Export User-DAG Assignments
/// This method allows you to export existing User-DAG assignments for a project.
///
///
@@ -609,9 +605,9 @@ public async Task SwitchDagAsync(string token, RedcapDag dag, Content co
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// userDagMapping
/// csv, json [default], xml
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// User-DAG assignments for the project in the format specified
- public async Task ExportUserDagAssignmentAsync(string token, Content content, ReturnFormat format = ReturnFormat.json, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportUserDagAssignmentAsync(string token, Content content, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
var exportUserDagAssignmentResult = string.Empty;
try
@@ -625,7 +621,7 @@ public async Task ExportUserDagAssignmentAsync(string token, Content con
{ "token", token },
{ "content", content.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
exportUserDagAssignmentResult = await this.SendPostRequestAsync(payload, _uri);
return exportUserDagAssignmentResult;
@@ -638,8 +634,7 @@ public async Task ExportUserDagAssignmentAsync(string token, Content con
}
}
///
- /// POST
- /// Import User-DAG Assignments
+ /// Import User-DAG Assignments
/// This method allows you to assign users to any data access group.
/// NOTE: If you wish to modify an existing mapping, you *must* provide its unique username and group name.If the 'redcap_data_access_group' column is not provided, user will not assigned to any group.There should be only one record per username.
///
@@ -663,9 +658,9 @@ public async Task ExportUserDagAssignmentAsync(string token, Content con
/// fl_dt_person, fl_site
/// global_user,
///
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Number of User-DAG assignments added or updated
- public async Task ImportUserDagAssignmentAsync(string token, Content content, RedcapAction action, ReturnFormat format, List data, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ImportUserDagAssignmentAsync(string token, Content content, RedcapAction action, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
var ImportUserDagAssignmentResults = string.Empty;
try
@@ -680,7 +675,7 @@ public async Task ImportUserDagAssignmentAsync(string token, Content
{ "content", content.GetDisplayName() },
{ "action", action.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "data", _serializedData }
};
// Execute request
@@ -697,7 +692,6 @@ public async Task ImportUserDagAssignmentAsync(string token, Content
#region Events
///
- /// API Version 1.0.0+
/// From Redcap Version 4.7.0
///
/// Export Events
@@ -713,9 +707,9 @@ public async Task ImportUserDagAssignmentAsync(string token, Content
///
/// csv, json [default], xml
///
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Events for the project in the format specified
- public async Task ExportEventsAsync(string token, ReturnFormat format = ReturnFormat.json, string[] arms = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportEventsAsync(string token, RedcapFormat format, string[] arms, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -725,7 +719,7 @@ public async Task ExportEventsAsync(string token, ReturnFormat format =
this.CheckToken(token);
if (arms.Length < 1)
{
- throw new InvalidOperationException($"Please specify the arm you wish to export the events from.");
+ throw new ArgumentNullException($"Please specify the arm you wish to export the events from.");
}
var payload = new Dictionary
@@ -733,7 +727,7 @@ public async Task ExportEventsAsync(string token, ReturnFormat format =
{ "token", token },
{ "content", Content.Event.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
// Optional
if (arms?.Length > 0)
@@ -758,10 +752,9 @@ public async Task ExportEventsAsync(string token, ReturnFormat format =
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.11.0
+ /// From Redcap Version 6.11.0
///
- /// Export Events
+ /// Export Events
/// This method allows you to export the events for a project
/// NOTE: This only works for longitudinal projects.
///
@@ -775,9 +768,9 @@ public async Task ExportEventsAsync(string token, ReturnFormat format =
/// event
/// csv, json [default], xml
///
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Events for the project in the format specified
- public async Task ExportEventsAsync(string token, Content content = Content.Event, ReturnFormat format = ReturnFormat.json, string[] arms = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportEventsAsync(string token, Content content, RedcapFormat format, string[] arms, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -787,7 +780,7 @@ public async Task ExportEventsAsync(string token, Content content = Cont
this.CheckToken(token);
if (arms.Length < 1)
{
- throw new InvalidOperationException($"Please specify the arm you wish to export the events from.");
+ throw new ArgumentNullException($"Please specify the arm you wish to export the events from.");
}
var payload = new Dictionary
@@ -795,7 +788,7 @@ public async Task ExportEventsAsync(string token, Content content = Cont
{ "token", token },
{ "content", content.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
// Optional
if (arms?.Length > 0)
@@ -820,8 +813,7 @@ public async Task ExportEventsAsync(string token, Content content = Cont
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.11.0
+ /// From Redcap Version 6.11.0
///
/// Import Events
/// This method allows you to import Events into a project or to update existing Events' attributes, such as the event name, days offset, etc. The unique event name of an Event cannot be changed because it is auto-generated by REDCap. Please note that the only way to update an existing Event is to provide the unique_event_name attribute, and if the unique_event_name attribute is missing for an Event being imported (when override=0), it will assume it to be a new Event that should be created. Notice: Because of the 'override' parameter's destructive nature, this method may only use override=1 for projects in Development status.
@@ -842,9 +834,9 @@ public async Task ExportEventsAsync(string token, Content content = Cont
/// "offset_max":"0","unique_event_name":"visit_2_arm_1"}]
///
/// csv, json [default], xml
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Number of Events imported
- public async Task ImportEventsAsync(string token, Override overRideBehavior, ReturnFormat format, List data, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ImportEventsAsync(string token, Override overRideBehavior, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -854,7 +846,7 @@ public async Task ImportEventsAsync(string token, Override overRideBe
this.CheckToken(token);
if (data.Count < 1)
{
- throw new InvalidOperationException($"Events can not be empty or null");
+ throw new ArgumentNullException($"Events can not be empty or null");
}
var _serializedData = JsonConvert.SerializeObject(data);
var payload = new Dictionary
@@ -864,7 +856,7 @@ public async Task ImportEventsAsync(string token, Override overRideBe
{ "action", RedcapAction.Import.GetDisplayName() },
{ "format", format.GetDisplayName() },
{ "override", overRideBehavior.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "data", _serializedData }
};
// Execute request
@@ -882,10 +874,9 @@ public async Task ImportEventsAsync(string token, Override overRideBe
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.11.0
+ /// From Redcap Version 6.11.0
///
- /// Import Events
+ /// Import Events
/// This method allows you to import Events into a project or to update existing Events' attributes, such as the event name, days offset, etc. The unique event name of an Event cannot be changed because it is auto-generated by REDCap. Please note that the only way to update an existing Event is to provide the unique_event_name attribute, and if the unique_event_name attribute is missing for an Event being imported (when override=0), it will assume it to be a new Event that should be created. Notice: Because of the 'override' parameter's destructive nature, this method may only use override=1 for projects in Development status.
/// NOTE: This only works for longitudinal projects.
///
@@ -895,7 +886,7 @@ public async Task ImportEventsAsync(string token, Override overRideBe
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// event
/// import
- /// 0 - false [default], 1 - true — You may use override=1 as a 'delete all + import' action in order to erase all existing Events in the project while importing new Events. If override=0, then you can only add new Events or modify existing ones.
+ /// 0 - false [default], 1 - true — You may use override=1 as a 'delete all + import' action in order to erase all existing Events in the project while importing new Events. If override=0, then you can only add new Events or modify existing ones.
///
/// Contains the required attributes 'event_name' (referring to the name/label of the event) and 'arm_num' (referring to the arm number to which the event belongs - assumes '1' if project only contains one arm). In order to modify an existing event, you must provide the attribute 'unique_event_name' (referring to the auto-generated unique event name of the given event). If the project utilizes the Scheduling module, the you may optionally provide the following attributes, which must be numerical: day_offset, offset_min, offset_max. If the day_offset is not provided, then the events will be auto-numbered in the order in which they are provided in the API request.
/// [{"event_name":"Baseline","arm_num":"1","day_offset":"1","offset_min":"0",
@@ -906,9 +897,9 @@ public async Task ImportEventsAsync(string token, Override overRideBe
/// "offset_max":"0","unique_event_name":"visit_2_arm_1"}]
///
/// csv, json [default], xml
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Number of Events imported
- public async Task ImportEventsAsync(string token, Content content, RedcapAction action, Override overRideBehavior, ReturnFormat format, List data, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ImportEventsAsync(string token, Content content, RedcapAction action, Override overrideBehavior, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -918,7 +909,7 @@ public async Task ImportEventsAsync(string token, Content content, Re
this.CheckToken(token);
if (data.Count < 1)
{
- throw new InvalidOperationException($"Events can not be empty or null");
+ throw new ArgumentNullException($"Events can not be empty or null");
}
var _serializedData = JsonConvert.SerializeObject(data);
var payload = new Dictionary
@@ -927,8 +918,8 @@ public async Task ImportEventsAsync(string token, Content content, Re
{ "content", content.GetDisplayName() },
{ "action", action.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "override", overRideBehavior.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "override", overrideBehavior.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "data", _serializedData }
};
// Execute request
@@ -946,11 +937,10 @@ public async Task ImportEventsAsync(string token, Content content, Re
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.11.0
+ /// From Redcap Version 6.11.0
///
- /// Delete Events
- /// This method allows you to delete Events from a project.
+ /// Delete Events
+ /// This method allows you to delete Events from a project.
/// Notice: Because of this method's destructive nature, it is only available for use for projects in Development status.
/// Additionally, please be aware that deleting an event will automatically delete any records/data that have been collected under that event (this is non-reversible data loss).
/// NOTE: This only works for longitudinal projects.
@@ -959,10 +949,10 @@ public async Task ImportEventsAsync(string token, Content content, Re
///
/// To use this method, you must have API Import/Update privileges *and* Project Design/Setup privileges in the project.
///
- ///
+ /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// Array of unique event names
/// Number of Events deleted
- public async Task DeleteEventsAsync(string token, string[] events = null)
+ public async Task DeleteEventsAsync(string token, string[] events)
{
try
{
@@ -972,7 +962,7 @@ public async Task DeleteEventsAsync(string token, string[] events = null
this.CheckToken(token);
if (events.Length < 1)
{
- throw new InvalidOperationException($"No events to delete...");
+ throw new ArgumentNullException($"No events to delete...");
}
var payload = new Dictionary
@@ -1004,11 +994,10 @@ public async Task DeleteEventsAsync(string token, string[] events = null
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.11.0
+ /// From Redcap Version 6.11.0
///
- /// Delete Events
- /// This method allows you to delete Events from a project.
+ /// Delete Events
+ /// This method allows you to delete Events from a project.
/// Notice: Because of this method's destructive nature, it is only available for use for projects in Development status.
/// Additionally, please be aware that deleting an event will automatically delete any records/data that have been collected under that event (this is non-reversible data loss).
/// NOTE: This only works for longitudinal projects.
@@ -1017,12 +1006,12 @@ public async Task DeleteEventsAsync(string token, string[] events = null
///
/// To use this method, you must have API Import/Update privileges *and* Project Design/Setup privileges in the project.
///
- ///
- ///
- ///
+ /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
+ /// event
+ /// delete
/// Array of unique event names
/// Number of Events deleted
- public async Task DeleteEventsAsync(string token, Content content, RedcapAction action, string[] events = null)
+ public async Task DeleteEventsAsync(string token, Content content, RedcapAction action, string[] events)
{
try
{
@@ -1066,13 +1055,13 @@ public async Task DeleteEventsAsync(string token, Content content, Redca
#region Field Names
///
- /// Export List of Export Field Names (i.e. variables used during exports and imports)
+ /// Export List of Export Field Names (i.e. variables used during exports and imports)
///
/// This method returns a list of the export/import-specific version of field names for all fields (or for one field, if desired) in a project.
/// This is mostly used for checkbox fields because during data exports and data imports, checkbox fields have a different variable name used than the exact one defined for them in the Online Designer and Data Dictionary, in which *each checkbox option* gets represented as its own export field name in the following format: field_name + triple underscore + converted coded value for the choice.
/// For non-checkbox fields, the export field name will be exactly the same as the original field name.
/// Note: The following field types will be automatically removed from the list returned by this method since they cannot be utilized during the data import process: 'calc', 'file', and 'descriptive'.
- ///
+ ///
/// The list that is returned will contain the three following attributes for each field/choice: 'original_field_name', 'choice_value', and 'export_field_name'.
/// The choice_value attribute represents the raw coded value for a checkbox choice.For non-checkbox fields, the choice_value attribute will always be blank/empty.
/// The export_field_name attribute represents the export/import-specific version of that field name.
@@ -1083,12 +1072,12 @@ public async Task DeleteEventsAsync(string token, Content content, Redca
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// csv, json [default], xml
/// A field's variable name. By default, all fields are returned, but if field is provided, then it will only the export field name(s) for that field. If the field name provided is invalid, it will return an error.
- /// csv, json [default], xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json [default], xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// The list that is returned will contain the original field name (variable) of the field and also the export field name(s) of that field.
/// Returns a list of the export/import-specific version of field names for all fields (or for one field, if desired) in a project in the format specified and ordered by their field order .
/// The list that is returned will contain the three following attributes for each field/choice: 'original_field_name', 'choice_value', and 'export_field_name'. The choice_value attribute represents the raw coded value for a checkbox choice. For non-checkbox fields, the choice_value attribute will always be blank/empty. The export_field_name attribute represents the export/import-specific version of that field name.
///
- public async Task ExportFieldNamesAsync(string token, ReturnFormat format = ReturnFormat.json, string field = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportFieldNamesAsync(string token, RedcapFormat format = RedcapFormat.json, string field = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -1101,7 +1090,7 @@ public async Task ExportFieldNamesAsync(string token, ReturnFormat forma
{ "token", token },
{ "content", Content.ExportFieldNames.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
if (!IsNullOrEmpty(field))
@@ -1123,13 +1112,13 @@ public async Task ExportFieldNamesAsync(string token, ReturnFormat forma
///
- /// Export List of Export Field Names (i.e. variables used during exports and imports)
+ /// Export List of Export Field Names (i.e. variables used during exports and imports)
///
/// This method returns a list of the export/import-specific version of field names for all fields (or for one field, if desired) in a project.
/// This is mostly used for checkbox fields because during data exports and data imports, checkbox fields have a different variable name used than the exact one defined for them in the Online Designer and Data Dictionary, in which *each checkbox option* gets represented as its own export field name in the following format: field_name + triple underscore + converted coded value for the choice.
/// For non-checkbox fields, the export field name will be exactly the same as the original field name.
/// Note: The following field types will be automatically removed from the list returned by this method since they cannot be utilized during the data import process: 'calc', 'file', and 'descriptive'.
- ///
+ ///
/// The list that is returned will contain the three following attributes for each field/choice: 'original_field_name', 'choice_value', and 'export_field_name'.
/// The choice_value attribute represents the raw coded value for a checkbox choice.For non-checkbox fields, the choice_value attribute will always be blank/empty.
/// The export_field_name attribute represents the export/import-specific version of that field name.
@@ -1141,12 +1130,12 @@ public async Task ExportFieldNamesAsync(string token, ReturnFormat forma
/// exportFieldNames
/// csv, json [default], xml
/// A field's variable name. By default, all fields are returned, but if field is provided, then it will only the export field name(s) for that field. If the field name provided is invalid, it will return an error.
- /// csv, json [default], xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json [default], xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// The list that is returned will contain the original field name (variable) of the field and also the export field name(s) of that field.
/// Returns a list of the export/import-specific version of field names for all fields (or for one field, if desired) in a project in the format specified and ordered by their field order .
/// The list that is returned will contain the three following attributes for each field/choice: 'original_field_name', 'choice_value', and 'export_field_name'. The choice_value attribute represents the raw coded value for a checkbox choice. For non-checkbox fields, the choice_value attribute will always be blank/empty. The export_field_name attribute represents the export/import-specific version of that field name.
///
- public async Task ExportFieldNamesAsync(string token, Content content = Content.ExportFieldNames, ReturnFormat format = ReturnFormat.json, string field = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportFieldNamesAsync(string token, Content content = Content.ExportFieldNames, RedcapFormat format = RedcapFormat.json, string field = null, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -1159,7 +1148,7 @@ public async Task ExportFieldNamesAsync(string token, Content content =
{ "token", token },
{ "content", content.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
if (!IsNullOrEmpty(field))
@@ -1182,13 +1171,16 @@ public async Task ExportFieldNamesAsync(string token, Content content =
#region Files
///
- /// API Version 1.0.0+
- /// Export a File
+ /// Export a File
/// This method allows you to download a document that has been attached to an individual record for a File Upload field. Please note that this method may also be used for Signature fields (i.e. File Upload fields with 'signature' validation type).
/// Note about export rights: Please be aware that Data Export user rights will be applied to this API request.For example, if you have 'No Access' data export rights in the project, then the API file export will fail and return an error. And if you have 'De-Identified' or 'Remove all tagged Identifier fields' data export rights, then the API file export will fail and return an error *only if* the File Upload field has been tagged as an Identifier field.To make sure that your API request does not return an error, you should have 'Full Data Set' export rights in the project.
+ ///
+ /// How to obtain the filename of the file:
+ /// The MIME type of the file, along with the name of the file and its extension, can be found in the header of the returned response.Thus in order to determine these attributes of the file being exported, you will need to parse the response header. Example: content-type = application / vnd.openxmlformats - officedocument.wordprocessingml.document; name='FILE_NAME.docx'
///
///
- /// To use this method, you must have API Export privileges in the project.
+ /// To use this method, you must have API Export privileges in the project.
+ ///
///
///
/// The MIME type of the file, along with the name of the file and its extension, can be found in the header of the returned response. Thus in order to determine these attributes of the file being exported, you will need to parse the response header. Example: content-type = application/vnd.openxmlformats-officedocument.wordprocessingml.document; name='FILE_NAME.docx'
@@ -1198,10 +1190,10 @@ public async Task ExportFieldNamesAsync(string token, Content content =
/// the name of the field that contains the file
/// the unique event name - only for longitudinal projects
/// (only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal). Default value is '1'.
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'.
/// File path which the file will be saved.
/// the contents of the file
- public async Task ExportFileAsync(string token, string record, string field, string eventName, string repeatInstance = "1", OnErrorFormat onErrorFormat = OnErrorFormat.json, string filePath = null)
+ public async Task ExportFileAsync(string token, string record, string field, string eventName, string repeatInstance = "1", RedcapReturnFormat returnFormat = RedcapReturnFormat.json, string filePath = null)
{
try
{
@@ -1223,15 +1215,15 @@ public async Task ExportFileAsync(string token, string record, string fi
}
if (IsNullOrEmpty(record))
{
- throw new InvalidOperationException($"No record provided to export");
+ throw new ArgumentNullException($"No record provided to export");
}
if (IsNullOrEmpty(field) || IsNullOrEmpty(eventName))
{
- throw new InvalidOperationException($"No field provided to export");
+ throw new ArgumentNullException($"No field provided to export");
}
if (IsNullOrEmpty(eventName))
{
- throw new InvalidOperationException($"No eventName provided to export");
+ throw new ArgumentNullException($"No eventName provided to export");
}
var payload = new Dictionary
{
@@ -1241,7 +1233,7 @@ public async Task ExportFileAsync(string token, string record, string fi
{ "record", record },
{ "field", field },
{ "event", eventName },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "repeat_instance", repeatInstance }
};
// Execute request
@@ -1259,14 +1251,16 @@ public async Task ExportFileAsync(string token, string record, string fi
}
///
- /// API Version 1.0.0+
- /// Export a File
- /// **Allows for file download to a path.**
+ /// Export a File
/// This method allows you to download a document that has been attached to an individual record for a File Upload field. Please note that this method may also be used for Signature fields (i.e. File Upload fields with 'signature' validation type).
/// Note about export rights: Please be aware that Data Export user rights will be applied to this API request.For example, if you have 'No Access' data export rights in the project, then the API file export will fail and return an error. And if you have 'De-Identified' or 'Remove all tagged Identifier fields' data export rights, then the API file export will fail and return an error *only if* the File Upload field has been tagged as an Identifier field.To make sure that your API request does not return an error, you should have 'Full Data Set' export rights in the project.
+ ///
+ /// How to obtain the filename of the file:
+ /// The MIME type of the file, along with the name of the file and its extension, can be found in the header of the returned response.Thus in order to determine these attributes of the file being exported, you will need to parse the response header. Example: content-type = application / vnd.openxmlformats - officedocument.wordprocessingml.document; name='FILE_NAME.docx'
///
///
- /// To use this method, you must have API Export privileges in the project.
+ /// To use this method, you must have API Export privileges in the project.
+ ///
///
///
/// The MIME type of the file, along with the name of the file and its extension, can be found in the header of the returned response. Thus in order to determine these attributes of the file being exported, you will need to parse the response header. Example: content-type = application/vnd.openxmlformats-officedocument.wordprocessingml.document; name='FILE_NAME.docx'
@@ -1281,7 +1275,7 @@ public async Task ExportFileAsync(string token, string record, string fi
/// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'.
/// File path which the file will be saved.
/// the file name that was exported
- public async Task ExportFileAsync(string token, Content content, RedcapAction action, string record, string field, string eventName, string repeatInstance = "1", OnErrorFormat onErrorFormat = OnErrorFormat.json, string filePath = null)
+ public async Task ExportFileAsync(string token, Content content, RedcapAction action, string record, string field, string eventName, string repeatInstance = "1", RedcapReturnFormat onErrorFormat = RedcapReturnFormat.json, string filePath = null)
{
try
{
@@ -1331,8 +1325,7 @@ public async Task ExportFileAsync(string token, Content content, RedcapA
}
///
- /// API Version 1.0.0+
- /// Import a File
+ /// Import a File
/// This method allows you to upload a document that will be attached to an individual record for a File Upload field. Please note that this method may NOT be used for Signature fields (i.e. File Upload fields with 'signature' validation type) because a signature can only be captured and stored using the web interface.
///
///
@@ -1346,9 +1339,9 @@ public async Task ExportFileAsync(string token, Content content, RedcapA
/// (only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal). Default value is '1'.
/// The File you be imported, contents of the file
/// the path where the file is located
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'.
/// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
- public async Task ImportFileAsync(string token, string record, string field, string eventName, string repeatInstance, string fileName, string filePath, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ImportFileAsync(string token, string record, string field, string eventName, string repeatInstance, string fileName, string filePath, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -1368,7 +1361,7 @@ public async Task ImportFileAsync(string token, string record, string fi
{new StringContent(record), "record" },
{new StringContent(field), "field" },
{new StringContent(eventName), "event" },
- {new StringContent(onErrorFormat.GetDisplayName()), "returnFormat" }
+ {new StringContent(returnFormat.GetDisplayName()), "returnFormat" }
};
if (!IsNullOrEmpty(repeatInstance))
{
@@ -1389,7 +1382,7 @@ public async Task ImportFileAsync(string token, string record, string fi
else
{
// add the binary file in specific content type
- _fileContent = new ByteArrayContent(File.ReadAllBytes(_binaryFile));
+ _fileContent = new ByteArrayContent(System.IO.File.ReadAllBytes(_binaryFile));
_fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
payload.Add(_fileContent, "file", _fileName);
}
@@ -1407,8 +1400,7 @@ public async Task ImportFileAsync(string token, string record, string fi
}
///
- /// API Version 1.0.0+
- /// Import a File
+ /// Import a File
/// This method allows you to upload a document that will be attached to an individual record for a File Upload field. Please note that this method may NOT be used for Signature fields (i.e. File Upload fields with 'signature' validation type) because a signature can only be captured and stored using the web interface.
///
///
@@ -1424,9 +1416,9 @@ public async Task ImportFileAsync(string token, string record, string fi
/// (only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal). Default value is '1'.
/// The File you be imported, contents of the file
/// the path where the file is located
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'.
/// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
- public async Task ImportFileAsync(string token, Content content, RedcapAction action, string record, string field, string eventName, string repeatInstance, string fileName, string filePath, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ImportFileAsync(string token, Content content, RedcapAction action, string record, string field, string eventName, string repeatInstance, string fileName, string filePath, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -1446,7 +1438,7 @@ public async Task ImportFileAsync(string token, Content content, RedcapA
{new StringContent(record), "record" },
{new StringContent(field), "field" },
{new StringContent(eventName), "event" },
- {new StringContent(onErrorFormat.GetDisplayName()), "returnFormat" }
+ {new StringContent(returnFormat.GetDisplayName()), "returnFormat" }
};
if (!IsNullOrEmpty(repeatInstance))
{
@@ -1467,7 +1459,7 @@ public async Task ImportFileAsync(string token, Content content, RedcapA
else
{
// add the binary file in specific content type
- _fileContent = new ByteArrayContent(File.ReadAllBytes(_binaryFile));
+ _fileContent = new ByteArrayContent(System.IO.File.ReadAllBytes(_binaryFile));
_fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
payload.Add(_fileContent, "file", _fileName);
}
@@ -1485,8 +1477,7 @@ public async Task ImportFileAsync(string token, Content content, RedcapA
}
///
- /// API Version 1.0.0+
- /// Delete a File
+ /// Delete a File
/// This method allows you to remove a document that has been attached to an individual record for a File Upload field. Please note that this method may also be used for Signature fields (i.e. File Upload fields with 'signature' validation type).
///
///
@@ -1497,9 +1488,9 @@ public async Task ImportFileAsync(string token, Content content, RedcapA
/// the name of the field that contains the file
/// the unique event name - only for longitudinal projects
/// (only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal). Default value is '1'.
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// String
- public async Task DeleteFileAsync(string token, string record, string field, string eventName, string repeatInstance, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task DeleteFileAsync(string token, string record, string field, string eventName, string repeatInstance, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -1515,7 +1506,7 @@ public async Task DeleteFileAsync(string token, string record, string fi
{new StringContent(record), "record" },
{new StringContent(field), "field" },
{new StringContent(eventName), "event" },
- {new StringContent(onErrorFormat.GetDisplayName()), "returnFormat" }
+ {new StringContent(returnFormat.GetDisplayName()), "returnFormat" }
};
if (!IsNullOrEmpty(repeatInstance))
{
@@ -1541,8 +1532,7 @@ public async Task DeleteFileAsync(string token, string record, string fi
}
///
- /// API Version 1.0.0+
- /// Delete a File
+ /// Delete a File
/// This method allows you to remove a document that has been attached to an individual record for a File Upload field. Please note that this method may also be used for Signature fields (i.e. File Upload fields with 'signature' validation type).
///
///
@@ -1555,9 +1545,9 @@ public async Task DeleteFileAsync(string token, string record, string fi
/// the name of the field that contains the file
/// the unique event name - only for longitudinal projects
/// (only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal). Default value is '1'.
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// String
- public async Task DeleteFileAsync(string token, Content content, RedcapAction action, string record, string field, string eventName, string repeatInstance, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task DeleteFileAsync(string token, Content content, RedcapAction action, string record, string field, string eventName, string repeatInstance, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -1573,7 +1563,7 @@ public async Task DeleteFileAsync(string token, Content content, RedcapA
{new StringContent(record), "record" },
{new StringContent(field), "field" },
{new StringContent(eventName), "event" },
- {new StringContent(onErrorFormat.GetDisplayName()), "returnFormat" }
+ {new StringContent(returnFormat.GetDisplayName()), "returnFormat" }
};
if (!IsNullOrEmpty(repeatInstance))
{
@@ -1598,119 +1588,344 @@ public async Task DeleteFileAsync(string token, Content content, RedcapA
}
}
#endregion Files
- #region Instruments
+ #region File Repository
///
- /// API Version 1.0.0+
- /// Export Instruments (Data Entry Forms)
- /// This method allows you to export a list of the data collection instruments for a project.
- /// This includes their unique instrument name as seen in the second column of the Data Dictionary, as well as each instrument's corresponding instrument label, which is seen on a project's left-hand menu when entering data. The instruments will be ordered according to their order in the project.
+ /// From Redcap Version 13.1
+ ///
+ /// Create a New Folder in the File Repository
+ ///
+ /// This method allows you to create a new folder in the File Repository.
+ /// You may optionally provide the folder_id of the parent folder under which you wish this folder to be created.
+ /// Providing a dag_id and/or role_id will allow you to restrict access to only users within a specific DAG (Data Access Group) or User Role, respectively.
+ ///
///
+ ///
///
- /// To use this method, you must have API Export privileges in the project.
+ /// To use this method, you must have API Import/Update privileges and File Repository privileges in the project.
///
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
+ /// fileRepository
+ /// createFolder
+ /// The desired name of the folder to be created (max length = 150 characters)
/// csv, json [default], xml
- /// Instruments for the project in the format specified and will be ordered according to their order in the project.
- public async Task ExportInstrumentsAsync(string token, ReturnFormat format = ReturnFormat.json)
+ /// the folder_id of a specific folder in the File Repository for which you wish to create this sub-folder. If none is provided, the folder will be created in the top-level directory of the File Repository.
+ /// the dag_id of the DAG (Data Access Group) to which you wish to restrict access for this folder. If none is provided, the folder will accessible to users in all DAGs and users in no DAGs.
+ /// the role_id of the User Role to which you wish to restrict access for this folder. If none is provided, the folder will accessible to users in all User Roles and users in no User Roles.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ ///
+ /// The folder_id of the new folder created in the specified format.
For example, if using format=json, the output would look similar to this: [{folder_id:45}].
+ public async Task CreateFolderFileRepositoryAsync(string token, Content content, RedcapAction action, string name, RedcapFormat format, string folderId = default, string dagId = default, string roleId = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
- try
+ /*
+ * Check the required parameters for empty or null
+ */
+ if (IsNullOrEmpty(token))
{
- /*
- * Check for presence of token
- */
- this.CheckToken(token);
- var payload = new Dictionary
- {
- { "token", token },
- { "content", Content.Instrument.GetDisplayName() },
- { "format", format.GetDisplayName() }
- };
- // Execute request
- return await this.SendPostRequestAsync(payload, _uri);
+ throw new ArgumentNullException("Please provide a valid Redcap token.");
}
- catch (Exception Ex)
+ if (IsNullOrEmpty(name))
{
- /*
- * We'll just log the error and return the error message.
- */
- Log.Error($"{Ex.Message}");
- return Ex.Message;
+ throw new ArgumentNullException("Please provide a valid name for the folder to create in the Repository.");
+ }
+ var payload = new Dictionary
+ {
+ { "token", token },
+ { "content", content.GetDisplayName() },
+ { "action", action.GetDisplayName() },
+ { "format", format.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() }
+ };
+ // Optional
+ if (!IsNullOrEmpty(folderId))
+ {
+ payload.Add("folder_id", folderId);
+ }
+ if (!IsNullOrEmpty(dagId))
+ {
+ payload.Add("dag_id", dagId);
+ }
+ if (!IsNullOrEmpty(roleId))
+ {
+ payload.Add("role_id", roleId);
}
- }
+ // Execute send request
+ return await this.SendPostRequestAsync(payload, _uri);
+
+ }
///
- /// API Version 1.0.0+
- /// Export Instruments (Data Entry Forms)
- /// This method allows you to export a list of the data collection instruments for a project.
- /// This includes their unique instrument name as seen in the second column of the Data Dictionary, as well as each instrument's corresponding instrument label, which is seen on a project's left-hand menu when entering data. The instruments will be ordered according to their order in the project.
+ /// From Redcap Version 13.1
+ ///
+ /// Export a List of Files/Folders from the File Repository
+ ///
///
///
- /// To use this method, you must have API Export privileges in the project.
+ /// To use this method, you must have API Export privileges and File Repository privileges in the project.
///
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
- /// instrument
+ /// fileRepository
+ /// list
/// csv, json [default], xml
- /// Instruments for the project in the format specified and will be ordered according to their order in the project.
- public async Task ExportInstrumentsAsync(string token, Content content = Content.Instrument, ReturnFormat format = ReturnFormat.json)
+ /// the folder_id of a specific folder in the File Repository for which you wish to export a list of its files and sub-folders. If none is provided, the top-level directory of the File Repository will be used.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// The list of all files and folders within a given sub-folder in the File Repository in the format specified.
+ public async Task ExportFilesFoldersFileRepositoryAsync(string token, Content content = Content.FileRepository, RedcapAction action = RedcapAction.List, RedcapFormat format = RedcapFormat.json, string folderId = null, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
- try
+ /*
+ * Check the required parameters for empty or null
+ */
+ if (IsNullOrEmpty(token))
{
- /*
- * Check for presence of token
- */
- this.CheckToken(token);
- var payload = new Dictionary
- {
- { "token", token },
- { "content", content.GetDisplayName() },
- { "format", format.GetDisplayName() }
- };
- // Execute request
- return await this.SendPostRequestAsync(payload, _uri);
+ throw new ArgumentNullException("Please provide a valid Redcap token.");
}
- catch (Exception Ex)
+ var payload = new Dictionary
{
- /*
- * We'll just log the error and return the error message.
- */
- Log.Error($"{Ex.Message}");
- return Ex.Message;
+ { "token", token },
+ { "content", content.GetDisplayName() },
+ { "action", action.GetDisplayName() },
+ { "format", format.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() }
+ };
+ // Optional
+ if (!IsNullOrEmpty(folderId))
+ {
+ payload.Add("folder_id", folderId);
}
- }
+ // Execute send request
+ return await this.SendPostRequestAsync(payload, _uri);
+ }
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.4.0
- /// Export PDF file of Data Collection Instruments (either as blank or with data)
- /// This method allows you to export a PDF file for any of the following: 1) a single data collection instrument (blank), 2) all instruments (blank), 3) a single instrument (with data from a single record), 4) all instruments (with data from a single record), or 5) all instruments (with data from ALL records).
- /// This is the exact same PDF file that is downloadable from a project's data entry form in the web interface, and additionally, the user's privileges with regard to data exports will be applied here just like they are when downloading the PDF in the web interface (e.g., if they have de-identified data export rights, then it will remove data from certain fields in the PDF).
- /// If the user has 'No Access' data export rights, they will not be able to use this method, and an error will be returned.
+ /// From Redcap Version 13.1
+ /// Export a File from the File Repository
///
///
- /// To use this method, you must have API Export privileges in the project.
+ /// To use this method, you must have API Export privileges and File Repository privileges in the project.
///
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
- /// the record ID. The value is blank by default. If record is blank, it will return the PDF as blank (i.e. with no data). If record is provided, it will return a single instrument or all instruments containing data from that record only.
- /// the unique event name - only for longitudinal projects. For a longitudinal project, if record is not blank and event is blank, it will return data for all events from that record. If record is not blank and event is not blank, it will return data only for the specified event from that record.
- /// the unique instrument name as seen in the second column of the Data Dictionary. The value is blank by default, which returns all instruments. If record is not blank and instrument is blank, it will return all instruments for that record.
- /// [The value of this parameter does not matter and is ignored.] If this parameter is passed with any value, it will export all instruments (and all events, if longitudinal) with data from all records. Note: If this parameter is passed, the parameters record, event, and instrument will be ignored.
- /// csv, json [default] , xml- The returnFormat is only used with regard to the format of any error messages that might be returned.
- /// A PDF file containing one or all data collection instruments from the project, in which the instruments will be blank (no data), contain data from a single record, or contain data from all records in the project, depending on the parameters passed in the API request.
- public async Task ExportPDFInstrumentsAsync(string token, string recordId = null, string eventName = null, string instrument = null, bool allRecord = false, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ /// fileRepository
+ /// export
+ /// the doc_id of the file in the File Repository
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// the contents of the file
+ public async Task ExportFileFileRepositoryAsync(string token, Content content, RedcapAction action, string docId = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
- try
+ /*
+ * Check the required parameters for empty or null
+ */
+ if (IsNullOrEmpty(token))
{
- /*
- * Check for presence of token
- */
- this.CheckToken(token);
-
+ throw new ArgumentNullException("Please provide a valid Redcap token.");
+ }
+ var payload = new Dictionary
+ {
+ { "token", token },
+ { "content", content.GetDisplayName() },
+ { "action", action.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() }
+ };
+ // Optional
+ if (!IsNullOrEmpty(docId))
+ {
+ payload.Add("doc_id", docId);
+ }
+
+ // Execute send request
+ return await this.SendPostRequestAsync(payload, _uri);
+ }
+ ///
+ /// From Redcap Version 13.1
+ /// Import a File into the File Repository
+ ///
+ ///
+ ///
+ /// To use this method, you must have API Import/Update privileges and File Repository privileges in the project.
+ ///
+ /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
+ /// fileRepository
+ /// import
+ /// the contents of the file
+ /// the folder_id of a specific folder in the File Repository where you wish to store the file. If none is provided, the file will be stored in the top-level directory of the File Repository.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// string
+ public async Task ImportFileRepositoryAsync(string token, Content content = Content.FileRepository, RedcapAction action = RedcapAction.Import, string file = null, string folderId = null, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
+ {
+ /*
+ * Check the required parameters for empty or null
+ */
+ if (IsNullOrEmpty(token))
+ {
+ throw new ArgumentNullException("Please provide a valid Redcap token.");
+ }
+ if (IsNullOrEmpty(file))
+ {
+ throw new ArgumentNullException("Please provide a file to import.");
+ }
+ var payload = new Dictionary
+ {
+ { "token", token },
+ { "content", content.GetDisplayName() },
+ { "action", action.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() }
+ };
+ // Optional
+ if (!IsNullOrEmpty(folderId))
+ {
+ payload.Add("folder_id", folderId);
+ }
+
+ // Execute send request
+ return await this.SendPostRequestAsync(payload, _uri);
+ }
+ ///
+ /// From Redcap Version 13.1
+ /// Delete a File from the File Repository
+ ///
+ ///
+ ///
+ /// To use this method, you must have API Import/Update privileges and File Repository privileges in the project.
+ ///
+ /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
+ /// fileRepository
+ /// delete
+ /// the doc_id of the file in the File Repository
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// string
+ public async Task DeleteFileRepositoryAsync(string token, Content content = Content.FileRepository, RedcapAction action = RedcapAction.Delete, string docId = null, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
+ {
+ /*
+ * Check the required parameters for empty or null
+ */
+ if (IsNullOrEmpty(token))
+ {
+ throw new ArgumentNullException("Please provide a valid Redcap token.");
+ }
+ if (IsNullOrEmpty(docId))
+ {
+ throw new ArgumentNullException("Please provide a document id to delete.");
+ }
+ var payload = new Dictionary
+ {
+ { "token", token },
+ { "content", content.GetDisplayName() },
+ { "action", action.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() }
+ };
+ // Execute send request
+ return await this.SendPostRequestAsync(payload, _uri);
+ }
+ #endregion File Repository
+ #region Instruments
+
+ ///
+ /// Export Instruments (Data Entry Forms)
+ /// This method allows you to export a list of the data collection instruments for a project.
+ /// This includes their unique instrument name as seen in the second column of the Data Dictionary, as well as each instrument's corresponding instrument label, which is seen on a project's left-hand menu when entering data. The instruments will be ordered according to their order in the project.
+ ///
+ ///
+ /// To use this method, you must have API Export privileges in the project.
+ ///
+ /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
+ /// csv, json [default], xml
+ /// Instruments for the project in the format specified and will be ordered according to their order in the project.
+ public async Task ExportInstrumentsAsync(string token, RedcapFormat format = RedcapFormat.json)
+ {
+ try
+ {
+ /*
+ * Check for presence of token
+ */
+ this.CheckToken(token);
+ var payload = new Dictionary
+ {
+ { "token", token },
+ { "content", Content.Instrument.GetDisplayName() },
+ { "format", format.GetDisplayName() }
+ };
+ // Execute request
+ return await this.SendPostRequestAsync(payload, _uri);
+ }
+ catch (Exception Ex)
+ {
+ /*
+ * We'll just log the error and return the error message.
+ */
+ Log.Error($"{Ex.Message}");
+ return Ex.Message;
+ }
+ }
+
+ ///
+ /// Export Instruments (Data Entry Forms)
+ /// This method allows you to export a list of the data collection instruments for a project.
+ /// This includes their unique instrument name as seen in the second column of the Data Dictionary, as well as each instrument's corresponding instrument label, which is seen on a project's left-hand menu when entering data. The instruments will be ordered according to their order in the project.
+ ///
+ ///
+ /// To use this method, you must have API Export privileges in the project.
+ ///
+ /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
+ /// instrument
+ /// csv, json [default], xml
+ /// Instruments for the project in the format specified and will be ordered according to their order in the project.
+ public async Task ExportInstrumentsAsync(string token, Content content = Content.Instrument, RedcapFormat format = RedcapFormat.json)
+ {
+ try
+ {
+ /*
+ * Check for presence of token
+ */
+ this.CheckToken(token);
+ var payload = new Dictionary
+ {
+ { "token", token },
+ { "content", content.GetDisplayName() },
+ { "format", format.GetDisplayName() }
+ };
+ // Execute request
+ return await this.SendPostRequestAsync(payload, _uri);
+ }
+ catch (Exception Ex)
+ {
+ /*
+ * We'll just log the error and return the error message.
+ */
+ Log.Error($"{Ex.Message}");
+ return Ex.Message;
+ }
+ }
+
+ ///
+ /// From Redcap Version 6.4.0
+ /// Export PDF file of Data Collection Instruments (either as blank or with data)
+ /// This method allows you to export a PDF file for any of the following: 1) a single data collection instrument (blank), 2) all instruments (blank), 3) a single instrument (with data from a single record), 4) all instruments (with data from a single record), or 5) all instruments (with data from ALL records).
+ /// This is the exact same PDF file that is downloadable from a project's data entry form in the web interface, and additionally, the user's privileges with regard to data exports will be applied here just like they are when downloading the PDF in the web interface (e.g., if they have de-identified data export rights, then it will remove data from certain fields in the PDF).
+ /// If the user has 'No Access' data export rights, they will not be able to use this method, and an error will be returned.
+ ///
+ ///
+ /// To use this method, you must have API Export privileges in the project.
+ ///
+ /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
+ /// the record ID. The value is blank by default. If record is blank, it will return the PDF as blank (i.e. with no data). If record is provided, it will return a single instrument or all instruments containing data from that record only.
+ /// the unique event name - only for longitudinal projects. For a longitudinal project, if record is not blank and event is blank, it will return data for all events from that record. If record is not blank and event is not blank, it will return data only for the specified event from that record.
+ /// the unique instrument name as seen in the second column of the Data Dictionary. The value is blank by default, which returns all instruments. If record is not blank and instrument is blank, it will return all instruments for that record.
+ /// [The value of this parameter does not matter and is ignored.] If this parameter is passed with any value, it will export all instruments (and all events, if longitudinal) with data from all records. Note: If this parameter is passed, the parameters record, event, and instrument will be ignored.
+ /// csv, json [default] , xml- The returnFormat is only used with regard to the format of any error messages that might be returned.
+ /// A PDF file containing one or all data collection instruments from the project, in which the instruments will be blank (no data), contain data from a single record, or contain data from all records in the project, depending on the parameters passed in the API request.
+ public async Task ExportPDFInstrumentsAsync(string token, string recordId = default, string eventName = default, string instrument = default, bool allRecord = false, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
+ {
+ try
+ {
+ /*
+ * Check for presence of token
+ */
+ this.CheckToken(token);
+
var payload = new Dictionary
{
{ "token", token },
{ "content", Content.Pdf.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
// Add all optional parameters
if (!IsNullOrEmpty(recordId))
@@ -1743,9 +1958,8 @@ public async Task ExportPDFInstrumentsAsync(string token, string recordI
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 11.4.4
- /// Export PDF file of Data Collection Instruments (either as blank or with data)
+ /// From Redcap Version 11.4.4
+ /// Export PDF file of Data Collection Instruments (either as blank or with data)
/// This method allows you to export a PDF file for any of the following: 1) a single data collection instrument (blank), 2) all instruments (blank), 3) a single instrument (with data from a single record), 4) all instruments (with data from a single record), or 5) all instruments (with data from ALL records).
/// This is the exact same PDF file that is downloadable from a project's data entry form in the web interface, and additionally, the user's privileges with regard to data exports will be applied here just like they are when downloading the PDF in the web interface (e.g., if they have de-identified data export rights, then it will remove data from certain fields in the PDF).
/// If the user has 'No Access' data export rights, they will not be able to use this method, and an error will be returned.
@@ -1762,7 +1976,7 @@ public async Task ExportPDFInstrumentsAsync(string token, string recordI
/// Set to TRUE to return a compact-formatted PDF that excludes fields that have no data saved and excludes unselected multiple choice options, thus producing a smaller PDF file. If set to FALSE, all fields will be displayed normally.
/// csv, json [default] , xml- The returnFormat is only used with regard to the format of any error messages that might be returned.
/// A PDF file containing one or all data collection instruments from the project, in which the instruments will be blank (no data), contain data from a single record, or contain data from all records in the project, depending on the parameters passed in the API request.
- public async Task ExportPDFInstrumentsAsync(string token, Content content = Content.Pdf, string recordId = null, string eventName = null, string instrument = null, bool allRecords = false, bool compactDisplay = false, OnErrorFormat returnFormat = OnErrorFormat.json)
+ public async Task ExportPDFInstrumentsAsync(string token, Content content = Content.Pdf, string recordId = default, string eventName = default, string instrument = default, bool allRecords = false, bool compactDisplay = false, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -1812,10 +2026,9 @@ public async Task ExportPDFInstrumentsAsync(string token, Content conten
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.4.0
+ /// From Redcap Version 6.4.0
/// **Allows for file download to a path.**
- /// Export PDF file of Data Collection Instruments (either as blank or with data)
+ /// Export PDF file of Data Collection Instruments (either as blank or with data)
/// This method allows you to export a PDF file for any of the following: 1) a single data collection instrument (blank), 2) all instruments (blank), 3) a single instrument (with data from a single record), 4) all instruments (with data from a single record), or 5) all instruments (with data from ALL records).
/// This is the exact same PDF file that is downloadable from a project's data entry form in the web interface, and additionally, the user's privileges with regard to data exports will be applied here just like they are when downloading the PDF in the web interface (e.g., if they have de-identified data export rights, then it will remove data from certain fields in the PDF).
/// If the user has 'No Access' data export rights, they will not be able to use this method, and an error will be returned.
@@ -1829,9 +2042,9 @@ public async Task ExportPDFInstrumentsAsync(string token, Content conten
/// the unique instrument name as seen in the second column of the Data Dictionary. The value is blank by default, which returns all instruments. If record is not blank and instrument is blank, it will return all instruments for that record.
/// [The value of this parameter does not matter and is ignored.] If this parameter is passed with any value, it will export all instruments (and all events, if longitudinal) with data from all records. Note: If this parameter is passed, the parameters record, event, and instrument will be ignored.
/// the path where the file is located
- /// csv, json [default] , xml- The returnFormat is only used with regard to the format of any error messages that might be returned.
+ /// csv, json [default] , xml- The returnFormat is only used with regard to the format of any error messages that might be returned.
/// A PDF file containing one or all data collection instruments from the project, in which the instruments will be blank (no data), contain data from a single record, or contain data from all records in the project, depending on the parameters passed in the API request.
- public async Task ExportPDFInstrumentsAsync(string token, string recordId = null, string eventName = null, string instrument = null, bool allRecord = false, string filePath = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportPDFInstrumentsAsync(string token, string recordId = default, string eventName = default, string instrument = default, bool allRecord = false, string filePath = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -1851,7 +2064,7 @@ public async Task ExportPDFInstrumentsAsync(string token, string recordI
{
{ "token", token },
{ "content", Content.Pdf.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "filePath", $@"{filePath}" }
};
// Add all optional parameters
@@ -1885,10 +2098,9 @@ public async Task ExportPDFInstrumentsAsync(string token, string recordI
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 4.7.0
+ /// From Redcap Version 4.7.0
///
- /// Export Instrument-Event Mappings
+ /// Export Instrument-Event Mappings
/// This method allows you to export the instrument-event mappings for a project (i.e., how the data collection instruments are designated for certain events in a longitudinal project).
/// NOTE: This only works for longitudinal projects.
///
@@ -1898,9 +2110,9 @@ public async Task ExportPDFInstrumentsAsync(string token, string recordI
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// csv, json [default], xml
/// an array of arm numbers that you wish to pull events for (by default, all events are pulled)
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Instrument-event mappings for the project in the format specified
- public async Task ExportInstrumentMappingAsync(string token, ReturnFormat format = ReturnFormat.json, string[] arms = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportInstrumentMappingAsync(string token, RedcapFormat format = RedcapFormat.json, string[] arms = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -1913,7 +2125,7 @@ public async Task ExportInstrumentMappingAsync(string token, ReturnForma
{ "token", token },
{ "content", Content.FormEventMapping.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
// Add all optional parameters
if (arms?.Length > 0)
@@ -1937,10 +2149,9 @@ public async Task ExportInstrumentMappingAsync(string token, ReturnForma
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 4.7.0
+ /// From Redcap Version 4.7.0
///
- /// Export Instrument-Event Mappings
+ /// Export Instrument-Event Mappings
/// This method allows you to export the instrument-event mappings for a project (i.e., how the data collection instruments are designated for certain events in a longitudinal project).
/// NOTE: This only works for longitudinal projects.
///
@@ -1951,9 +2162,9 @@ public async Task ExportInstrumentMappingAsync(string token, ReturnForma
/// formEventMapping
/// csv, json [default], xml
/// an array of arm numbers that you wish to pull events for (by default, all events are pulled)
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Instrument-event mappings for the project in the format specified
- public async Task ExportInstrumentMappingAsync(string token, Content content = Content.FormEventMapping, ReturnFormat format = ReturnFormat.json, string[] arms = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportInstrumentMappingAsync(string token, Content content, RedcapFormat format, string[] arms = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -1966,7 +2177,7 @@ public async Task ExportInstrumentMappingAsync(string token, Content con
{ "token", token },
{ "content", content.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
// Add all optional parameters
if (arms?.Length > 0)
@@ -1990,28 +2201,27 @@ public async Task ExportInstrumentMappingAsync(string token, Content con
}
///
- /// API Version 1.0.0+
- /// FFrom Redcap Version 4.7.0
+ /// From Redcap Version 4.7.0
///
- /// Import Instrument-Event Mappings
+ /// Import Instrument-Event Mappings
/// This method allows you to import Instrument-Event Mappings into a project (this corresponds to the 'Designate Instruments for My Events' page in the project).
/// NOTE: This only works for longitudinal projects.
///
///
/// To use this method, you must have API Import/Update privileges *and* Project Design/Setup privileges in the project.
///
+ ///
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// csv, json [default], xml
- ///
/// Contains the attributes 'arm_num' (referring to the arm number), 'unique_event_name' (referring to the auto-generated unique event name of the given event), and 'form' (referring to the unique form name of the given data collection instrument), in which they are provided in the specified format.
/// JSON Example:[{"arm_num":"1","unique_event_name":"baseline_arm_1","form":"demographics"},
/// {"arm_num":"1","unique_event_name":"visit_1_arm_1","form":"day_3"},
/// {"arm_num":"1","unique_event_name":"visit_1_arm_1","form":"other"},
/// {"arm_num":"1","unique_event_name":"visit_2_arm_1","form":"other"}]
///
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Number of Instrument-Event Mappings imported
- public async Task ImportInstrumentMappingAsync(string token, ReturnFormat format, List data, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ImportInstrumentMappingAsync(string token, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -2026,7 +2236,7 @@ public async Task ImportInstrumentMappingAsync(string token, ReturnFo
{ "token", token },
{ "content", Content.FormEventMapping.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "data", _serializedData }
};
// Execute request
@@ -2043,29 +2253,28 @@ public async Task ImportInstrumentMappingAsync(string token, ReturnFo
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 4.7.0
+ /// From Redcap Version 4.7.0
///
- /// Import Instrument-Event Mappings
+ /// Import Instrument-Event Mappings
/// This method allows you to import Instrument-Event Mappings into a project (this corresponds to the 'Designate Instruments for My Events' page in the project).
/// NOTE: This only works for longitudinal projects.
///
///
/// To use this method, you must have API Import/Update privileges *and* Project Design/Setup privileges in the project.
///
+ ///
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// formEventMapping
/// csv, json [default], xml
- ///
/// Contains the attributes 'arm_num' (referring to the arm number), 'unique_event_name' (referring to the auto-generated unique event name of the given event), and 'form' (referring to the unique form name of the given data collection instrument), in which they are provided in the specified format.
/// JSON Example:[{"arm_num":"1","unique_event_name":"baseline_arm_1","form":"demographics"},
/// {"arm_num":"1","unique_event_name":"visit_1_arm_1","form":"day_3"},
/// {"arm_num":"1","unique_event_name":"visit_1_arm_1","form":"other"},
/// {"arm_num":"1","unique_event_name":"visit_2_arm_1","form":"other"}]
///
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Number of Instrument-Event Mappings imported
- public async Task ImportInstrumentMappingAsync(string token, Content content, ReturnFormat format, List data, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ImportInstrumentMappingAsync(string token, Content content, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -2080,7 +2289,7 @@ public async Task ImportInstrumentMappingAsync(string token, Content
{ "token", token },
{ "content", content.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "data", _serializedData }
};
// Execute request
@@ -2098,14 +2307,14 @@ public async Task ImportInstrumentMappingAsync(string token, Content
#endregion Instruments
#region Logging
///
- /// API @Version 10.8
- /// POST
- /// Export Logging
+ /// From Redcap Version 10.8
+ /// Export Logging
/// This method allows you to export the logging (audit trail) of all changes made to this project, including data exports, data changes, project metadata changes, modification of user rights, etc.
+ ///
KEY:
Filter by event (logtype):
export = Data export,
manage = Manage/Design,
user = User or role created-updated-deleted,
record = Record created-updated-deleted,
record_add = Record created (only),
record_edit = Record updated(only),
record_delete = Record deleted(only),
lock_record = Record locking and e-signatures,
page_view = Page View
+ ///
///
- /// To use this method, you must have API Export privileges in the project.
+ /// To use this method, you must have API Export privileges *and* Logging privileges in the project.
///
- ///
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// log
/// csv, json [default], xml
@@ -2115,9 +2324,9 @@ public async Task ImportInstrumentMappingAsync(string token, Content
/// To return only the events belong to specific DAG (referring to group_id), provide a dag. If not specified, it will assume all dags.
/// To return only the events that have been logged *after* a given date/time, provide a timestamp in the format YYYY-MM-DD HH:MM (e.g., '2017-01-01 17:00' for January 1, 2017 at 5:00 PM server time). If not specified, it will assume no begin time.
/// To return only records that have been logged *before* a given date/time, provide a timestamp in the format YYYY-MM-DD HH:MM (e.g., '2017-01-01 17:00' for January 1, 2017 at 5:00 PM server time). If not specified, it will use the current server time.
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// List of all changes made to this project, including data exports, data changes, and the creation or deletion of users.
- public async Task ExportLoggingAsync(string token, Content content, ReturnFormat format = ReturnFormat.json, LogType logType = LogType.All, string user = null, string record = null, string dag = null, string beginTime = null, string endTime = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportLoggingAsync(string token, Content content, RedcapFormat format = RedcapFormat.json, LogType logType = LogType.All, string user = default, string record = default, string dag = default, string beginTime = default, string endTime = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
var exportLoggingResults = string.Empty;
try
@@ -2130,28 +2339,28 @@ public async Task ExportLoggingAsync(string token, Content content, Retu
{ "token", token },
{ "content", content.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "logtype", logType.GetDisplayName() }
};
// Optional
- if (!string.IsNullOrEmpty(user))
+ if (!IsNullOrEmpty(user))
{
payload.Add("user", user);
}
- if (!string.IsNullOrEmpty(record))
+ if (!IsNullOrEmpty(record))
{
payload.Add("record", record);
}
- if (!string.IsNullOrEmpty(dag))
+ if (!IsNullOrEmpty(dag))
{
payload.Add("dag", dag);
}
- if (!string.IsNullOrEmpty(beginTime))
+ if (!IsNullOrEmpty(beginTime))
{
payload.Add("beginTime", beginTime);
}
- if (!string.IsNullOrEmpty(endTime))
+ if (!IsNullOrEmpty(endTime))
{
payload.Add("endTime", endTime);
}
@@ -2167,9 +2376,8 @@ public async Task ExportLoggingAsync(string token, Content content, Retu
#endregion
#region Metadata
///
- /// API Version 1.0.0+
- /// From Redcap Version 3.4.0+
- /// Export Metadata (Data Dictionary)
+ /// From Redcap Version 3.4.0+
+ /// Export Metadata (Data Dictionary)
/// This method allows you to export the metadata for a project
///
///
@@ -2180,9 +2388,9 @@ public async Task ExportLoggingAsync(string token, Content content, Retu
/// csv, json [default], xml
/// an array of field names specifying specific fields you wish to pull (by default, all metadata is pulled)
/// an array of form names specifying specific data collection instruments for which you wish to pull metadata (by default, all metadata is pulled). NOTE: These 'forms' are not the form label values that are seen on the webpages, but instead they are the unique form names seen in Column B of the data dictionary.
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Metadata from the project (i.e. Data Dictionary values) in the format specified ordered by the field order
- public async Task ExportMetaDataAsync(string token, Content content = Content.MetaData, ReturnFormat format = ReturnFormat.json, string[] fields = null, string[] forms = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportMetaDataAsync(string token, Content content, RedcapFormat format, string[] fields = default, string[] forms = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -2195,7 +2403,7 @@ public async Task ExportMetaDataAsync(string token, Content content = Co
{ "token", token },
{ "content", content.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
// Optional
if (fields?.Length > 0)
@@ -2224,8 +2432,7 @@ public async Task ExportMetaDataAsync(string token, Content content = Co
}
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 3.4.0+
+ /// From Redcap Version 3.4.0+
/// Export Metadata (Data Dictionary)
/// This method allows you to export the metadata for a project
///
@@ -2236,9 +2443,9 @@ public async Task ExportMetaDataAsync(string token, Content content = Co
/// csv, json [default], xml
/// an array of field names specifying specific fields you wish to pull (by default, all metadata is pulled)
/// an array of form names specifying specific data collection instruments for which you wish to pull metadata (by default, all metadata is pulled). NOTE: These 'forms' are not the form label values that are seen on the webpages, but instead they are the unique form names seen in Column B of the data dictionary.
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Metadata from the project (i.e. Data Dictionary values) in the format specified ordered by the field order
- public async Task ExportMetaDataAsync(string token, ReturnFormat format = ReturnFormat.json, string[] fields = null, string[] forms = null, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportMetaDataAsync(string token, RedcapFormat format = RedcapFormat.json, string[] fields = default, string[] forms = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -2251,7 +2458,7 @@ public async Task ExportMetaDataAsync(string token, ReturnFormat format
{ "token", token },
{ "content", Content.MetaData.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
// Optional
if (fields?.Length > 0)
@@ -2280,10 +2487,9 @@ public async Task ExportMetaDataAsync(string token, ReturnFormat format
}
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.11.0
+ /// From Redcap Version 6.11.0
///
- /// Import Metadata (Data Dictionary)
+ /// Import Metadata (Data Dictionary)
///
/// This method allows you to import metadata (i.e., Data Dictionary) into a project. Notice: Because of this method's destructive nature, it is only available for use for projects in Development status.
///
@@ -2294,9 +2500,9 @@ public async Task ExportMetaDataAsync(string token, ReturnFormat format
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// csv, json [default], xml
/// The formatted data to be imported.
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Number of fields imported
- public async Task ImportMetaDataAsync(string token, ReturnFormat format, List data, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ImportMetaDataAsync(string token, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -2310,7 +2516,7 @@ public async Task ImportMetaDataAsync(string token, ReturnFormat form
{ "token", token },
{ "content", Content.MetaData.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "data", _serializedData }
};
return await this.SendPostRequestAsync(payload, _uri);
@@ -2326,10 +2532,9 @@ public async Task ImportMetaDataAsync(string token, ReturnFormat form
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.11.0
+ /// From Redcap Version 6.11.0
///
- /// Import Metadata (Data Dictionary)
+ /// Import Metadata (Data Dictionary)
///
/// This method allows you to import metadata (i.e., Data Dictionary) into a project. Notice: Because of this method's destructive nature, it is only available for use for projects in Development status.
///
@@ -2341,9 +2546,9 @@ public async Task ImportMetaDataAsync(string token, ReturnFormat form
/// metadata
/// csv, json [default], xml
/// The formatted data to be imported.
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// Number of fields imported
- public async Task ImportMetaDataAsync(string token, Content content, ReturnFormat format, List data, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ImportMetaDataAsync(string token, Content content, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -2357,7 +2562,7 @@ public async Task ImportMetaDataAsync(string token, Content content,
{ "token", token },
{ "content", content.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "data", _serializedData }
};
return await this.SendPostRequestAsync(payload, _uri);
@@ -2374,10 +2579,9 @@ public async Task ImportMetaDataAsync(string token, Content content,
#endregion Metadata
#region Projects
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.11.0
+ /// From Redcap Version 6.11.0
///
- /// Create A New Project
+ /// Create A New Project
///
/// This method allows you to create a new REDCap project. A 64-character Super API Token is required for this method (as opposed to project-level API methods that require a regular 32-character token associated with the project-user). In the API request, you must minimally provide the project attributes 'project_title' and 'purpose' (with numerical value 0=Practice/Just for fun, 1=Other, 2=Research, 3=Quality Improvement, 4=Operational Support) when creating a project.
/// When a project is created with this method, the project will automatically be given all the project-level defaults just as if you created a new empty project via the web user interface, such as a automatically creating a single data collection instrument seeded with a single Record ID field and Form Status field, as well as (for longitudinal projects) one arm with one event. And if you intend to create your own arms or events immediately after creating the project, it is recommended that you utilize the override=1 parameter in the 'Import Arms' or 'Import Events' method, respectively, so that the default arm and event are removed when you add your own.Also, the user creating the project will automatically be added to the project as a user with full user privileges and a project-level API token, which could then be used for subsequent project-level API requests.
@@ -2386,7 +2590,6 @@ public async Task ImportMetaDataAsync(string token, Content content,
///
/// To use this method, you must have a Super API Token.
///
- /// To use this method, you must have a Super API Token.
///
/// The Super API Token specific to a user
/// csv, json [default], xml
@@ -2397,10 +2600,10 @@ public async Task ImportMetaDataAsync(string token, Content content,
/// JSON Example:
/// [{"project_title":"My New REDCap Project","purpose":"0"}]
///
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// default: NULL - The 'odm' parameter must be an XML string in CDISC ODM XML format that contains project metadata (fields, forms, events, arms) and might optionally contain data to be imported as well. The XML contained in this parameter can come from a REDCap Project XML export file from REDCap itself, or may come from another system that is capable of exporting projects and data in CDISC ODM format. If the 'odm' parameter is included in the API request, it will use the XML to import its contents into the newly created project. This will allow you not only to create the project with the API request, but also to import all fields, forms, and project attributes (and events and arms, if longitudinal) as well as record data all at the same time.
/// When a project is created, a 32-character project-level API Token is returned (associated with both the project and user creating the project). This token could then ostensibly be used to make subsequent API calls to this project, such as for adding new events, fields, records, etc.
- public async Task CreateProjectAsync(string token, ReturnFormat format, List data, OnErrorFormat onErrorFormat = OnErrorFormat.json, string odm = null)
+ public async Task CreateProjectAsync(string token, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, string odm = default)
{
try
{
@@ -2414,7 +2617,7 @@ public async Task CreateProjectAsync(string token, ReturnFormat forma
{ "token", token },
{ "content", Content.Project.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "data", _serializedData }
};
if (!IsNullOrEmpty(odm))
@@ -2435,10 +2638,9 @@ public async Task CreateProjectAsync(string token, ReturnFormat forma
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.11.0
+ /// From Redcap Version 6.11.0
///
- /// Create A New Project
+ /// Create A New Project
///
/// This method allows you to create a new REDCap project. A 64-character Super API Token is required for this method (as opposed to project-level API methods that require a regular 32-character token associated with the project-user). In the API request, you must minimally provide the project attributes 'project_title' and 'purpose' (with numerical value 0=Practice/Just for fun, 1=Other, 2=Research, 3=Quality Improvement, 4=Operational Support) when creating a project.
/// When a project is created with this method, the project will automatically be given all the project-level defaults just as if you created a new empty project via the web user interface, such as a automatically creating a single data collection instrument seeded with a single Record ID field and Form Status field, as well as (for longitudinal projects) one arm with one event. And if you intend to create your own arms or events immediately after creating the project, it is recommended that you utilize the override=1 parameter in the 'Import Arms' or 'Import Events' method, respectively, so that the default arm and event are removed when you add your own.Also, the user creating the project will automatically be added to the project as a user with full user privileges and a project-level API token, which could then be used for subsequent project-level API requests.
@@ -2459,10 +2661,10 @@ public async Task CreateProjectAsync(string token, ReturnFormat forma
/// JSON Example:
/// [{"project_title":"My New REDCap Project","purpose":"0"}]
///
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// default: NULL - The 'odm' parameter must be an XML string in CDISC ODM XML format that contains project metadata (fields, forms, events, arms) and might optionally contain data to be imported as well. The XML contained in this parameter can come from a REDCap Project XML export file from REDCap itself, or may come from another system that is capable of exporting projects and data in CDISC ODM format. If the 'odm' parameter is included in the API request, it will use the XML to import its contents into the newly created project. This will allow you not only to create the project with the API request, but also to import all fields, forms, and project attributes (and events and arms, if longitudinal) as well as record data all at the same time.
/// When a project is created, a 32-character project-level API Token is returned (associated with both the project and user creating the project). This token could then ostensibly be used to make subsequent API calls to this project, such as for adding new events, fields, records, etc.
- public async Task CreateProjectAsync(string token, Content content, ReturnFormat format, List data, OnErrorFormat onErrorFormat = OnErrorFormat.json, string odm = null)
+ public async Task CreateProjectAsync(string token, Content content, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, string odm = null)
{
try
{
@@ -2476,7 +2678,7 @@ public async Task CreateProjectAsync(string token, Content content, R
{ "token", token },
{ "content", content.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "data", _serializedData }
};
if (!IsNullOrEmpty(odm))
@@ -2497,8 +2699,7 @@ public async Task CreateProjectAsync(string token, Content content, R
}
///
- /// API Version 1.0.0+
- /// Import Project Information
+ /// Import Project Information
/// This method allows you to update some of the basic attributes of a given REDCap project, such as the project's title, if it is longitudinal, if surveys are enabled, etc. Its data format corresponds to the format in the API method Export Project Information.
///
///
@@ -2512,7 +2713,7 @@ public async Task CreateProjectAsync(string token, Content content, R
/// project_title, project_language, purpose, purpose_other, project_notes, custom_record_label, secondary_unique_field, is_longitudinal, surveys_enabled, scheduling_enabled, record_autonumbering_enabled, randomization_enabled, project_irb_number, project_grant_number, project_pi_firstname, project_pi_lastname, display_today_now_button
///
/// Returns the number of values accepted to be updated in the project settings (including values which remained the same before and after the import).
- public async Task ImportProjectInfoAsync(string token, Content content, ReturnFormat format, RedcapProjectInfo projectInfo)
+ public async Task ImportProjectInfoAsync(string token, Content content, RedcapFormat format, RedcapProjectInfo projectInfo)
{
try
{
@@ -2542,8 +2743,7 @@ public async Task ImportProjectInfoAsync(string token, Content content,
}
///
- /// API Version 1.0.0+
- /// Import Project Information
+ /// Import Project Information
/// This method allows you to update some of the basic attributes of a given REDCap project, such as the project's title, if it is longitudinal, if surveys are enabled, etc. Its data format corresponds to the format in the API method Export Project Information.
///
///
@@ -2556,7 +2756,7 @@ public async Task ImportProjectInfoAsync(string token, Content content,
/// project_title, project_language, purpose, purpose_other, project_notes, custom_record_label, secondary_unique_field, is_longitudinal, surveys_enabled, scheduling_enabled, record_autonumbering_enabled, randomization_enabled, project_irb_number, project_grant_number, project_pi_firstname, project_pi_lastname, display_today_now_button
///
/// Returns the number of values accepted to be updated in the project settings (including values which remained the same before and after the import).
- public async Task ImportProjectInfoAsync(string token, ReturnFormat format, RedcapProjectInfo projectInfo)
+ public async Task ImportProjectInfoAsync(string token, RedcapFormat format, RedcapProjectInfo projectInfo)
{
try
{
@@ -2587,8 +2787,7 @@ public async Task ImportProjectInfoAsync(string token, ReturnFormat form
}
///
- /// API Version 1.0.0+
- /// Export Project Information
+ /// Export Project Information
/// This method allows you to export some of the basic attributes of a given REDCap project, such as the project's title, if it is longitudinal, if surveys are enabled, the time the project was created and moved to production, etc.
///
///
@@ -2598,12 +2797,12 @@ public async Task ImportProjectInfoAsync(string token, ReturnFormat form
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// project
/// csv, json [default], xml
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
///
/// Attributes for the project in the format specified. For any values that are boolean, they will be represented as either a '0' (no/false) or '1' (yes/true). Also, all date/time values will be returned in Y-M-D H:M:S format. The following attributes will be returned:
/// project_id, project_title, creation_time, production_time, in_production, project_language, purpose, purpose_other, project_notes, custom_record_label, secondary_unique_field, is_longitudinal, surveys_enabled, scheduling_enabled, record_autonumbering_enabled, randomization_enabled, ddp_enabled, project_irb_number, project_grant_number, project_pi_firstname, project_pi_lastname, display_today_now_button
///
- public async Task ExportProjectInfoAsync(string token, Content content = Content.Project, ReturnFormat format = ReturnFormat.json, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportProjectInfoAsync(string token, Content content = Content.Project, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -2617,7 +2816,7 @@ public async Task ExportProjectInfoAsync(string token, Content content =
{ "token", token },
{ "content", content.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
return await this.SendPostRequestAsync(payload, _uri);
}
@@ -2631,8 +2830,7 @@ public async Task ExportProjectInfoAsync(string token, Content content =
}
}
///
- /// API Version 1.0.0+
- /// Export Project Information
+ /// Export Project Information
/// This method allows you to export some of the basic attributes of a given REDCap project, such as the project's title, if it is longitudinal, if surveys are enabled, the time the project was created and moved to production, etc.
///
///
@@ -2641,12 +2839,12 @@ public async Task ExportProjectInfoAsync(string token, Content content =
///
/// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project.
/// csv, json [default], xml
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
///
/// Attributes for the project in the format specified. For any values that are boolean, they will be represented as either a '0' (no/false) or '1' (yes/true). Also, all date/time values will be returned in Y-M-D H:M:S format. The following attributes will be returned:
/// project_id, project_title, creation_time, production_time, in_production, project_language, purpose, purpose_other, project_notes, custom_record_label, secondary_unique_field, is_longitudinal, surveys_enabled, scheduling_enabled, record_autonumbering_enabled, randomization_enabled, ddp_enabled, project_irb_number, project_grant_number, project_pi_firstname, project_pi_lastname, display_today_now_button
///
- public async Task ExportProjectInfoAsync(string token, ReturnFormat format = ReturnFormat.json, OnErrorFormat onErrorFormat = OnErrorFormat.json)
+ public async Task ExportProjectInfoAsync(string token, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json)
{
try
{
@@ -2660,7 +2858,7 @@ public async Task ExportProjectInfoAsync(string token, ReturnFormat form
{ "token", token },
{ "content", Content.Project.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
return await this.SendPostRequestAsync(payload, _uri);
}
@@ -2675,10 +2873,9 @@ public async Task ExportProjectInfoAsync(string token, ReturnFormat form
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.12.0
+ /// From Redcap Version 6.12.0
///
- /// Export Entire Project as REDCap XML File (containing metadata and data)
+ /// Export Entire Project as REDCap XML File (containing metadata and data)
/// The entire project(all records, events, arms, instruments, fields, and project attributes) can be downloaded as a single XML file, which is in CDISC ODM format(ODM version 1.3.1). This XML file can be used to create a clone of the project(including its data, optionally) on this REDCap server or on another REDCap server (it can be uploaded on the Create New Project page). Because it is in CDISC ODM format, it can also be used to import the project into another ODM-compatible system. NOTE: All the option paramters listed below ONLY apply to data returned if the 'returnMetadataOnly' parameter is set to FALSE (default). For this API method, ALL metadata (all fields, forms, events, and arms) will always be exported.Only the data returned can be filtered using the optional parameters.
/// Note about export rights: If the 'returnMetadataOnly' parameter is set to FALSE, then please be aware that Data Export user rights will be applied to any data returned from this API request. For example, if you have 'De-Identified' or 'Remove all tagged Identifier fields' data export rights, then some data fields *might* be removed and filtered out of the data set returned from the API. To make sure that no data is unnecessarily filtered out of your API request, you should have 'Full Data Set' export rights in the project.
///
@@ -2692,13 +2889,13 @@ public async Task ExportProjectInfoAsync(string token, ReturnFormat form
/// an array of record names specifying specific records you wish to pull (by default, all records are pulled)
/// an array of field names specifying specific fields you wish to pull (by default, all fields are pulled)
/// an array of unique event names that you wish to pull records for - only for longitudinal projects
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// true, false [default] - specifies whether or not to export the survey identifier field (e.g., 'redcap_survey_identifier') or survey timestamp fields (e.g., instrument+'_timestamp') when surveys are utilized in the project. If you do not pass in this flag, it will default to 'false'. If set to 'true', it will return the redcap_survey_identifier field and also the survey timestamp field for a particular survey when at least one field from that survey is being exported. NOTE: If the survey identifier field or survey timestamp fields are imported via API data import, they will simply be ignored since they are not real fields in the project but rather are pseudo-fields.
/// true, false [default] - specifies whether or not to export the 'redcap_data_access_group' field when data access groups are utilized in the project. If you do not pass in this flag, it will default to 'false'. NOTE: This flag is only viable if the user whose token is being used to make the API request is *not* in a data access group. If the user is in a group, then this flag will revert to its default value.
/// String of logic text (e.g., [age] > 30) for filtering the data to be returned by this API method, in which the API will only return the records (or record-events, if a longitudinal project) where the logic evaluates as TRUE. This parameter is blank/null by default unless a value is supplied. Please note that if the filter logic contains any incorrect syntax, the API will respond with an error message.
/// true, false [default] - TRUE will cause the XML returned to include all files uploaded for File Upload and Signature fields for all records in the project, whereas FALSE will cause all such fields not to be included. NOTE: Setting this option to TRUE can make the export very large and may prevent it from completing if the project contains many files or very large files.
/// The entire REDCap project's metadata (and data, if specified) will be returned in CDISC ODM format as a single XML string.
- public async Task ExportProjectXmlAsync(string token, Content content, bool returnMetadataOnly = false, string[] records = null, string[] fields = null, string[] events = null, OnErrorFormat onErrorFormat = OnErrorFormat.json, bool exportSurveyFields = false, bool exportDataAccessGroups = false, string filterLogic = null, bool exportFiles = false)
+ public async Task ExportProjectXmlAsync(string token, Content content, bool returnMetadataOnly = false, string[] records = default, string[] fields = default, string[] events = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, bool exportSurveyFields = false, bool exportDataAccessGroups = false, string filterLogic = default, bool exportFiles = false)
{
try
{
@@ -2711,7 +2908,7 @@ public async Task ExportProjectXmlAsync(string token, Content content, b
{
{ "token", token },
{ "content", content.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
// Optional
if (returnMetadataOnly)
@@ -2755,10 +2952,9 @@ public async Task ExportProjectXmlAsync(string token, Content content, b
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.12.0
+ /// From Redcap Version 6.12.0
///
- /// Export Entire Project as REDCap XML File (containing metadata and data)
+ /// Export Entire Project as REDCap XML File (containing metadata and data)
/// The entire project(all records, events, arms, instruments, fields, and project attributes) can be downloaded as a single XML file, which is in CDISC ODM format(ODM version 1.3.1). This XML file can be used to create a clone of the project(including its data, optionally) on this REDCap server or on another REDCap server (it can be uploaded on the Create New Project page). Because it is in CDISC ODM format, it can also be used to import the project into another ODM-compatible system. NOTE: All the option paramters listed below ONLY apply to data returned if the 'returnMetadataOnly' parameter is set to FALSE (default). For this API method, ALL metadata (all fields, forms, events, and arms) will always be exported.Only the data returned can be filtered using the optional parameters.
/// Note about export rights: If the 'returnMetadataOnly' parameter is set to FALSE, then please be aware that Data Export user rights will be applied to any data returned from this API request. For example, if you have 'De-Identified' or 'Remove all tagged Identifier fields' data export rights, then some data fields *might* be removed and filtered out of the data set returned from the API. To make sure that no data is unnecessarily filtered out of your API request, you should have 'Full Data Set' export rights in the project.
///
@@ -2771,13 +2967,13 @@ public async Task ExportProjectXmlAsync(string token, Content content, b
/// an array of record names specifying specific records you wish to pull (by default, all records are pulled)
/// an array of field names specifying specific fields you wish to pull (by default, all fields are pulled)
/// an array of unique event names that you wish to pull records for - only for longitudinal projects
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// true, false [default] - specifies whether or not to export the survey identifier field (e.g., 'redcap_survey_identifier') or survey timestamp fields (e.g., instrument+'_timestamp') when surveys are utilized in the project. If you do not pass in this flag, it will default to 'false'. If set to 'true', it will return the redcap_survey_identifier field and also the survey timestamp field for a particular survey when at least one field from that survey is being exported. NOTE: If the survey identifier field or survey timestamp fields are imported via API data import, they will simply be ignored since they are not real fields in the project but rather are pseudo-fields.
/// true, false [default] - specifies whether or not to export the 'redcap_data_access_group' field when data access groups are utilized in the project. If you do not pass in this flag, it will default to 'false'. NOTE: This flag is only viable if the user whose token is being used to make the API request is *not* in a data access group. If the user is in a group, then this flag will revert to its default value.
/// String of logic text (e.g., [age] > 30) for filtering the data to be returned by this API method, in which the API will only return the records (or record-events, if a longitudinal project) where the logic evaluates as TRUE. This parameter is blank/null by default unless a value is supplied. Please note that if the filter logic contains any incorrect syntax, the API will respond with an error message.
/// true, false [default] - TRUE will cause the XML returned to include all files uploaded for File Upload and Signature fields for all records in the project, whereas FALSE will cause all such fields not to be included. NOTE: Setting this option to TRUE can make the export very large and may prevent it from completing if the project contains many files or very large files.
/// The entire REDCap project's metadata (and data, if specified) will be returned in CDISC ODM format as a single XML string.
- public async Task ExportProjectXmlAsync(string token, bool returnMetadataOnly = false, string[] records = null, string[] fields = null, string[] events = null, OnErrorFormat onErrorFormat = OnErrorFormat.json, bool exportSurveyFields = false, bool exportDataAccessGroups = false, string filterLogic = null, bool exportFiles = false)
+ public async Task ExportProjectXmlAsync(string token, bool returnMetadataOnly = false, string[] records = default, string[] fields = default, string[] events = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, bool exportSurveyFields = false, bool exportDataAccessGroups = false, string filterLogic = default, bool exportFiles = false)
{
try
{
@@ -2790,7 +2986,7 @@ public async Task ExportProjectXmlAsync(string token, bool returnMetadat
{
{ "token", token },
{ "content", Content.ProjectXml.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() }
+ { "returnFormat", returnFormat.GetDisplayName() }
};
// Optional
if (returnMetadataOnly)
@@ -2836,9 +3032,8 @@ public async Task ExportProjectXmlAsync(string token, bool returnMetadat
#endregion Projects
#region Records
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.18.0
- /// Generate Next Record Name
+ /// From Redcap Version 6.18.0
+ /// Generate Next Record Name
/// To be used by projects with record auto-numbering enabled, this method exports the next potential record ID for a project. It generates the next record name by determining the current maximum numerical record ID and then incrementing it by one.
/// Note: This method does not create a new record, but merely determines what the next record name would be.
/// If using Data Access Groups (DAGs) in the project, this method accounts for the special formatting of the record name for users in DAGs (e.g., DAG-ID); in this case, it only assigns the next value for ID for all numbers inside a DAG. For example, if a DAG has a corresponding DAG number of 223 wherein records 223-1 and 223-2 already exist, then the next record will be 223-3 if the API user belongs to the DAG that has DAG number 223. (The DAG number is auto-assigned by REDCap for each DAG when the DAG is first created.) When generating a new record name in a DAG, the method considers all records in the entire project when determining the maximum record ID, including those that might have been originally created in that DAG but then later reassigned to another DAG.
@@ -2876,9 +3071,8 @@ public async Task GenerateNextRecordNameAsync(string token)
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 6.18.0
- /// Generate Next Record Name
+ /// From Redcap Version 6.18.0
+ /// Generate Next Record Name
/// To be used by projects with record auto-numbering enabled, this method exports the next potential record ID for a project. It generates the next record name by determining the current maximum numerical record ID and then incrementing it by one.
/// Note: This method does not create a new record, but merely determines what the next record name would be.
/// If using Data Access Groups (DAGs) in the project, this method accounts for the special formatting of the record name for users in DAGs (e.g., DAG-ID); in this case, it only assigns the next value for ID for all numbers inside a DAG. For example, if a DAG has a corresponding DAG number of 223 wherein records 223-1 and 223-2 already exist, then the next record will be 223-3 if the API user belongs to the DAG that has DAG number 223. (The DAG number is auto-assigned by REDCap for each DAG when the DAG is first created.) When generating a new record name in a DAG, the method considers all records in the entire project when determining the maximum record ID, including those that might have been originally created in that DAG but then later reassigned to another DAG.
@@ -2917,9 +3111,8 @@ public async Task GenerateNextRecordNameAsync(string token, Content cont
}
///
- /// API Version 1.0.0+
- /// From Redcap Version 11.4.0
- /// Export Records
+ /// From Redcap Version 11.4.0
+ /// Export Records
/// This method allows you to export a set of records for a project.
/// Note about export rights: Please be aware that Data Export user rights will be applied to this API request.For example, if you have 'No Access' data export rights in the project, then the API data export will fail and return an error. And if you have 'De-Identified' or 'Remove all tagged Identifier fields' data export rights, then some data fields *might* be removed and filtered out of the data set returned from the API. To make sure that no data is unnecessarily filtered out of your API request, you should have 'Full Data Set' export rights in the project.
///
@@ -2936,7 +3129,7 @@ public async Task GenerateNextRecordNameAsync(string token, Content cont
/// raw [default], label - export the raw coded values or labels for the options of multiple choice fields
/// raw [default], label - (for 'csv' format 'flat' type only) for the CSV headers, export the variable/field names (raw) or the field labels (label)
/// true, false [default] - specifies the format of checkbox field values specifically when exporting the data as labels (i.e., when rawOrLabel=label) in flat format (i.e., when type=flat). When exporting labels, by default (without providing the exportCheckboxLabel flag or if exportCheckboxLabel=false), all checkboxes will either have a value 'Checked' if they are checked or 'Unchecked' if not checked. But if exportCheckboxLabel is set to true, it will instead export the checkbox value as the checkbox option's label (e.g., 'Choice 1') if checked or it will be blank/empty (no value) if not checked. If rawOrLabel=false or if type=eav, then the exportCheckboxLabel flag is ignored. (The exportCheckboxLabel parameter is ignored for type=eav because 'eav' type always exports checkboxes differently anyway, in which checkboxes are exported with their true variable name (whereas the 'flat' type exports them as variable___code format), and another difference is that 'eav' type *always* exports checkbox values as the choice label for labels export, or as 0 or 1 (if unchecked or checked, respectively) for raw export.)
- /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
+ /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'.
/// true, false [default] - specifies whether or not to export the survey identifier field (e.g., 'redcap_survey_identifier') or survey timestamp fields (e.g., instrument+'_timestamp') when surveys are utilized in the project. If you do not pass in this flag, it will default to 'false'. If set to 'true', it will return the redcap_survey_identifier field and also the survey timestamp field for a particular survey when at least one field from that survey is being exported. NOTE: If the survey identifier field or survey timestamp fields are imported via API data import, they will simply be ignored since they are not real fields in the project but rather are pseudo-fields.
/// true, false [default] - specifies whether or not to export the 'redcap_data_access_group' field when data access groups are utilized in the project. If you do not pass in this flag, it will default to 'false'. NOTE: This flag is only viable if the user whose token is being used to make the API request is *not* in a data access group. If the user is in a group, then this flag will revert to its default value.
/// String of logic text (e.g., [age] > 30) for filtering the data to be returned by this API method, in which the API will only return the records (or record-events, if a longitudinal project) where the logic evaluates as TRUE. This parameter is blank/null by default unless a value is supplied. Please note that if the filter logic contains any incorrect syntax, the API will respond with an error message.
@@ -2946,7 +3139,7 @@ public async Task GenerateNextRecordNameAsync(string token, Content cont
/// If specified, force all numbers into same decimal format. You may choose to force all data values containing a decimal to have the same decimal character, which will be applied to all calc fields and number-validated text fields. Options include comma ',' or dot/full stop '.', but if left blank/null, then it will export numbers using the fields' native decimal format. Simply provide the value of either ',' or '.' for this parameter.
/// true, false [default] - specifies whether or not to export blank values for instrument complete status fields that have a gray status icon. All instrument complete status fields having a gray icon can be exported either as a blank value or as "0" (Incomplete). Blank values are recommended in a data export if the data will be re-imported into a REDCap project.
/// Data from the project in the format and type specified ordered by the record (primary key of project) and then by event id
- public async Task ExportRecordsAsync(string token, RedcapFormat format = RedcapFormat.json, RedcapDataType redcapDataType = RedcapDataType.flat, string[] records = null, string[] fields = null, string[] forms = null, string[] events = null, RawOrLabel rawOrLabel = RawOrLabel.raw, RawOrLabelHeaders rawOrLabelHeaders = RawOrLabelHeaders.raw, bool exportCheckboxLabel = false, OnErrorFormat onErrorFormat = OnErrorFormat.json, bool exportSurveyFields = false, bool exportDataAccessGroups = false, string filterLogic = null, DateTime? dateRangeBegin = null, DateTime? dateRangeEnd = null, string csvDelimiter = null, string decimalCharacter = null, bool exportBlankForGrayFormStatus = false)
+ public async Task ExportRecordsAsync(string token, RedcapFormat format = RedcapFormat.json, RedcapDataType redcapDataType = RedcapDataType.flat, string[] records = default, string[] fields = default, string[] forms = default, string[] events = default, RawOrLabel rawOrLabel = RawOrLabel.raw, RawOrLabelHeaders rawOrLabelHeaders = RawOrLabelHeaders.raw, bool exportCheckboxLabel = false, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, bool exportSurveyFields = false, bool exportDataAccessGroups = false, string filterLogic = null, DateTime? dateRangeBegin = default, DateTime? dateRangeEnd = default, string csvDelimiter = default, string decimalCharacter = default, bool exportBlankForGrayFormStatus = false)
{
try
{
@@ -2957,7 +3150,7 @@ public async Task ExportRecordsAsync(string token, RedcapFormat format =
{ "token", token },
{ "content", Content.Record.GetDisplayName() },
{ "format", format.GetDisplayName() },
- { "returnFormat", onErrorFormat.GetDisplayName() },
+ { "returnFormat", returnFormat.GetDisplayName() },
{ "type", redcapDataType.GetDisplayName() },
{"exportBlankForGrayFormStatus", exportBlankForGrayFormStatus.ToString() }
@@ -3039,9 +3232,8 @@ public async Task ExportRecordsAsync(string token, RedcapFormat format =
}
///