diff --git a/src/docs/version_001/docsStructure.ts b/src/docs/version_001/docsStructure.ts index 64a38ac..fdc46c2 100644 --- a/src/docs/version_001/docsStructure.ts +++ b/src/docs/version_001/docsStructure.ts @@ -164,6 +164,12 @@ export const versionOne: DocsStructure = { copy: 'copy.md', example: 'example.md', }, + { + title: 'Add Record', + folder: 'add_record', + copy: 'copy.md', + example: 'example.md', + }, ], }, { diff --git a/src/docs/version_001/resources/records/add_record/copy.md b/src/docs/version_001/resources/records/add_record/copy.md new file mode 100644 index 0000000..fb57327 --- /dev/null +++ b/src/docs/version_001/resources/records/add_record/copy.md @@ -0,0 +1,57 @@ +# Add Record {% #add-record %} + +This endpoint allows you to add a record to an app. + +## Path Parameters + +{% table %} + +- Parameter Name +- Data Type +- Description + +--- + +- appId +- `number` +- The id of the app or survey that the record will be added to. + +{% /table %} + +## Request Body Properties + +{% table %} + +- Property Name +- Data Type +- Description + +--- + +- FieldData +- `object` +- The field data to be included in the record when added. Each `key` should be an id of a field you want to populate and its `value` should be the value you want to place into that field. + +{% /table %} + +## Response Body Properties + +{% table %} + +- Property Name +- Data Type +- Description + +--- + +- recordId +- `number` +- The record id of the newly created record. + +--- + +- Warnings +- `string[]` +- A list of warnings related to the records creation. Will only be present if warnings were in fact generated by the request. + +{% /table %} diff --git a/src/docs/version_001/resources/records/add_record/example.md b/src/docs/version_001/resources/records/add_record/example.md new file mode 100644 index 0000000..dc15d9d --- /dev/null +++ b/src/docs/version_001/resources/records/add_record/example.md @@ -0,0 +1,56 @@ +# Add a record in an app + +{% code method="POST" heading="/Records/{appId}" defaultLanguage="bash" %} + +```bash +curl --location 'https://api.onspring.com/v1/Records/195' \ +--header 'Content-Type: application/json' \ +--data '{ + "FieldData": { + "6983": "A New Test Task", + "6984": "This is a test task.", + "6985": "12/25/2021", + "6986: "4118d53a-9121-4345-8682-07f23d606daa", + "6987": [4] + } +}' +``` + +```csharp +using Onspring.API.SDK.Helpers; + +var httpHelper = new HttpHelper( + config.baseUrl, + config.apiKey +); + +var fieldValues = new FieldAddEditContainer(); +fieldValues.Add(6983, "A New Test Task") +fieldValues.Add(6984, "This is a test task."); +fieldValues.Add(6985, "12/25/2021"); +fieldValues.Add(6986, "4118d53a-9121-4345-8682-07f23d606daa"); +fieldValues.Add(6987, new[] {4}) + +var result = httpHelper.CreateAppRecord(195, fieldValues); + +Console.WriteLine($"New Record Id is: {result.CreatedId}"); + +foreach (string warning in result.Warnings) +{ + Console.WriteLine($"Warning: {warning}"); +} + +``` + +{% /code %} + +{% code heading="RESPONSE" defaultLanguage="json" %} + +```json +{ + "recordId": 781, + "Warnings": ["A warning"] +} +``` + +{% /code %} diff --git a/src/docs/version_002/resources/records/save_record/example.md b/src/docs/version_002/resources/records/save_record/example.md index 8853f36..f6149f7 100644 --- a/src/docs/version_002/resources/records/save_record/example.md +++ b/src/docs/version_002/resources/records/save_record/example.md @@ -10,11 +10,11 @@ curl --location --request PUT 'https://api.onspring.com/Records' \ "appId": 195, "recordId": null, "fields": { - 6983: "A New Test Task", - 6984: "This is a test task.", - 6985: "12/25/2021", - 6986: "4118d53a-9121-4345-8682-07f23d606daa", - 6987: [4] + "6983": "A New Test Task", + "6984": "This is a test task.", + "6985": "12/25/2021", + "6986: "4118d53a-9121-4345-8682-07f23d606daa", + "6987": [4] } }' ```