docs: add get record by id section
This commit is contained in:
@@ -39,6 +39,11 @@
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.container>article>p>code,
|
||||
.container>article>table code {
|
||||
padding: 0.1rem 0.5rem;
|
||||
}
|
||||
|
||||
.container>article:nth-child(1)>h1 {
|
||||
color: #ee7203;
|
||||
font-size: 40px;
|
||||
|
||||
@@ -9,35 +9,30 @@ export const versionTwo: DocsStructure = {
|
||||
folder: 'introduction',
|
||||
copy: 'copy.md',
|
||||
example: 'example.md',
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
title: 'Authentication',
|
||||
folder: 'authentication',
|
||||
copy: 'copy.md',
|
||||
example: 'example.md',
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
title: 'Data Format',
|
||||
folder: 'data_format',
|
||||
copy: 'copy.md',
|
||||
example: 'example.md',
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
title: 'Pagination',
|
||||
folder: 'pagination',
|
||||
copy: 'copy.md',
|
||||
example: 'example.md',
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
title: 'Error Handling',
|
||||
folder: 'error_handling',
|
||||
copy: 'copy.md',
|
||||
example: 'example.md',
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
title: 'Resources',
|
||||
@@ -61,6 +56,12 @@ export const versionTwo: DocsStructure = {
|
||||
copy: 'copy.md',
|
||||
example: 'example.md',
|
||||
},
|
||||
{
|
||||
title: 'Get Record by Id',
|
||||
folder: 'get_record_by_id',
|
||||
copy: 'copy.md',
|
||||
example: 'example.md',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Get Record by Id {% #get-record-by-id %}
|
||||
|
||||
This endpoint returns a single [record](#records) based on the given record id.
|
||||
|
||||
## Path Parameters
|
||||
|
||||
{% table %}
|
||||
|
||||
- Parameter Name
|
||||
- Data Type
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- appId
|
||||
- `number`
|
||||
- The id of the app or survey that the record belongs to.
|
||||
|
||||
---
|
||||
|
||||
- recordId
|
||||
- `number`
|
||||
- The id of the record.
|
||||
|
||||
{% /table %}
|
||||
|
||||
## Query Parameters
|
||||
|
||||
{% table %}
|
||||
|
||||
- Parameter Name
|
||||
- Data Type
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- fieldIds
|
||||
- `string`
|
||||
- A comma-separated list of field ids to include in the response. If not specified, all fields will be returned.
|
||||
|
||||
---
|
||||
|
||||
- dataFormat
|
||||
- `string`
|
||||
- The [format](#data-format) of the field data in the response. Valid values are `raw` and `formatted`. If not specified, `raw` will be used.
|
||||
|
||||
{% /table %}
|
||||
@@ -0,0 +1,90 @@
|
||||
# Retrieving a record from an app
|
||||
|
||||
{% code heading="GET /Records/appId/{appID}/recordId/{recordID}" defaultLanguage="bash" %}
|
||||
|
||||
```bash
|
||||
curl --location 'https://api.onspring.com/Records/appId/195/recordId/1' \
|
||||
--header 'X-ApiKey: 000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000'
|
||||
```
|
||||
|
||||
```csharp
|
||||
using Onspring.API.SDK;
|
||||
|
||||
var onspringClient = new OnspringClient(
|
||||
config.BaseUrl,
|
||||
config.ApiKey
|
||||
);
|
||||
|
||||
var getRequest = new GetRecordRequest
|
||||
{
|
||||
AppId = 195,
|
||||
RecordId = 1,
|
||||
};
|
||||
|
||||
var getResponse = await onspringClient.GetRecordAsync(getRequest);
|
||||
var record = getResponse.Value;
|
||||
|
||||
foreach (var recordFieldValue in record.FieldData)
|
||||
{
|
||||
Console.WriteLine($"FieldId: {recordFieldValue.FieldId}, Type: {recordFieldValue.Type}, Value: {recordFieldValue.Value}");
|
||||
}
|
||||
```
|
||||
|
||||
```javascript
|
||||
import {
|
||||
GetRecordRequest,
|
||||
OnspringClient,
|
||||
} from 'onspring-api-sdk';
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
|
||||
const client = new OnspringClient(
|
||||
process.env.BASE_URL,
|
||||
process.env.API_KEY
|
||||
);
|
||||
|
||||
const request = new GetRecordRequest(195, 1);
|
||||
const res = await client.getRecordById(request);
|
||||
const record = res.data;
|
||||
|
||||
console.log(record);
|
||||
```
|
||||
|
||||
```python
|
||||
from OnspringApiSdk.OnspringClient import OnspringClient
|
||||
from OnspringApiSdk.Models import GetRecordByIdRequest
|
||||
from configparser import ConfigParser
|
||||
|
||||
request = GetRecordByIdRequest(appId=195, recordId=1)
|
||||
|
||||
response = client.GetRecordById(request)
|
||||
|
||||
print(f'Status Code: {response.statusCode}')
|
||||
print(f'AppId: {response.data.appId}')
|
||||
print(f'RecordId: {response.data.recordId}')
|
||||
|
||||
for field in response.data.fields:
|
||||
print(f'Type: {field.type}')
|
||||
print(f'FieldId: {field.fieldId}')
|
||||
print(f'Value: {field.GetResultValueString()}')
|
||||
```
|
||||
|
||||
{% /code %}
|
||||
|
||||
{% code heading="RESPONSE" defaultLanguage="json" %}
|
||||
|
||||
```json
|
||||
{
|
||||
"appId": 195,
|
||||
"recordId": 1,
|
||||
"fieldData": [
|
||||
{
|
||||
"type": "Integer",
|
||||
"fieldId": 6976,
|
||||
"value": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
{% /code %}
|
||||
@@ -1,3 +1,43 @@
|
||||
# Get Records by App {% #get-records-by-app %}
|
||||
|
||||
Some place holder text.
|
||||
This endpoint returns a [paged](#pagination) collection of [records](#records) for a given app or survey.
|
||||
|
||||
## Path Parameters
|
||||
|
||||
{% table %}
|
||||
|
||||
- Parameter Name
|
||||
- Data Type
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- appId
|
||||
- `number`
|
||||
- The id of the app or survey.
|
||||
|
||||
{% /table %}
|
||||
|
||||
## Query Parameters
|
||||
|
||||
**Note:** [Pagination](#pagination) query parameters can be used to control the number of records returned.
|
||||
|
||||
{% table %}
|
||||
|
||||
- Parameter Name
|
||||
- Data Type
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- fieldIds
|
||||
- `string`
|
||||
- A comma-separated list of field ids to include in the response. If not specified, all fields will be returned.
|
||||
|
||||
---
|
||||
|
||||
- dataFormat
|
||||
- `string`
|
||||
- The [format](#data-format) of the field data in the response. Valid values are `raw` and `formatted`. If not specified, `raw` will be used.
|
||||
|
||||
{% /table %}
|
||||
|
||||
@@ -42,6 +42,7 @@ for (const app of apps) {
|
||||
|
||||
```python
|
||||
from OnspringApiSdk.OnspringClient import OnspringClient
|
||||
from OnspringApiSdk.Models import GetRecordsByAppRequest
|
||||
from configparser import ConfigParser
|
||||
|
||||
cfg = ConfigParser()
|
||||
@@ -51,7 +52,8 @@ key = cfg['prod']['key']
|
||||
url = cfg['prod']['url']
|
||||
|
||||
client = OnspringClient(url, key)
|
||||
response = client.GetApps()
|
||||
request = GetRecordsByAppRequest(appId=195)
|
||||
response = client.GetRecordsByAppId(request)
|
||||
|
||||
print(f'Status Code: {response.statusCode}')
|
||||
print(f'Page Size: {response.data.pageSize}')
|
||||
@@ -59,10 +61,14 @@ print(f'Page Number: {response.data.pageNumber}')
|
||||
print(f'Total Pages: {response.data.totalPages}')
|
||||
print(f'Total Records: {response.data.totalRecords}')
|
||||
|
||||
for app in response.data.apps:
|
||||
print(f'Id: {app.id}')
|
||||
print(f'Name: {app.name}')
|
||||
print(f'href: {app.href}')
|
||||
for record in response.data.records:
|
||||
print(f'AppId: {record.appId}')
|
||||
print(f'RecordId: {record.recordId}')
|
||||
|
||||
for field in record.fields:
|
||||
print(f'Type: {field.type}')
|
||||
print(f'FieldId: {field.fieldId}')
|
||||
print(f'Value: {field.GetResultValueString()}')
|
||||
```
|
||||
|
||||
{% /code %}
|
||||
|
||||
Reference in New Issue
Block a user