docs: add get field by id section
This commit is contained in:
@@ -1 +1,19 @@
|
||||
# Get Field by Id {% #get-field-by-id %}
|
||||
|
||||
This endpoint returns a [Field](#fields) by its id.
|
||||
|
||||
## Path Parameters
|
||||
|
||||
{% table %}
|
||||
|
||||
- Property Name
|
||||
- Data Type
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- fieldId
|
||||
- `number`
|
||||
- The id of the field to retrieve.
|
||||
|
||||
{% /table %}
|
||||
|
||||
@@ -1 +1,98 @@
|
||||
# Retrieve a field by its id
|
||||
|
||||
{% code method="GET" heading="/Fields/id/{fieldId}" defaultLanguage="bash" %}
|
||||
|
||||
```bash
|
||||
curl --location 'https://api.onspring.com/Fields/id/6986' \
|
||||
--header 'X-ApiKey: 000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000'
|
||||
```
|
||||
|
||||
```csharp
|
||||
using Onspring.API.SDK;
|
||||
|
||||
var onspringClient = new OnspringClient(
|
||||
config.BaseUrl,
|
||||
config.ApiKey
|
||||
);
|
||||
|
||||
var response = await onspringClient.GetFieldAsync(6986);
|
||||
var field = response.Value;
|
||||
|
||||
Console.WriteLine($"{field.Id}");
|
||||
```
|
||||
|
||||
```javascript
|
||||
import { OnspringClient } from 'onspring-api-sdk';
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
|
||||
const client = new OnspringClient(
|
||||
process.env.BASE_URL,
|
||||
process.env.API_KEY
|
||||
);
|
||||
|
||||
const res = await client.getFieldById(6986);
|
||||
const field = res.data;
|
||||
|
||||
console.log(field);
|
||||
```
|
||||
|
||||
```python
|
||||
from OnspringApiSdk.OnspringClient import OnspringClient
|
||||
from configparser import ConfigParser
|
||||
|
||||
cfg = ConfigParser()
|
||||
cfg.read('config.ini')
|
||||
|
||||
key = cfg['prod']['key']
|
||||
url = cfg['prod']['url']
|
||||
|
||||
client = OnspringClient(url, key)
|
||||
response = client.GetFieldById(fieldId=6986)
|
||||
|
||||
print(f'Status Code: {response.statusCode}')
|
||||
print(f'Field Id: {response.data.id}')
|
||||
```
|
||||
|
||||
{% /code %}
|
||||
|
||||
{% code heading="RESPONSE" defaultLanguage="json" %}
|
||||
|
||||
```json
|
||||
{
|
||||
"multiplicity": "SingleSelect",
|
||||
"listId": 906,
|
||||
"values": [
|
||||
{
|
||||
"id": "4118d53a-9121-4345-8682-07f23d606daa",
|
||||
"name": "In Progress",
|
||||
"sortOrder": 1,
|
||||
"numericValue": 1.0,
|
||||
"color": "#db3e3e"
|
||||
},
|
||||
{
|
||||
"id": "1c1c5f7e-cd03-4b70-9790-0f83b24b5863",
|
||||
"name": "Complete",
|
||||
"sortOrder": 2,
|
||||
"numericValue": 2.0,
|
||||
"color": "#ffffff"
|
||||
},
|
||||
{
|
||||
"id": "42493542-f77c-4298-91a0-18455ba0c764",
|
||||
"name": "Not Started",
|
||||
"sortOrder": 3,
|
||||
"numericValue": 0.0,
|
||||
"color": "#ffffff"
|
||||
}
|
||||
],
|
||||
"id": 6986,
|
||||
"appId": 195,
|
||||
"name": "Status",
|
||||
"type": "List",
|
||||
"status": "Enabled",
|
||||
"isRequired": false,
|
||||
"isUnique": false
|
||||
}
|
||||
```
|
||||
|
||||
{% /code %}
|
||||
|
||||
@@ -2,6 +2,22 @@
|
||||
|
||||
This endpoint returns a [paged](#pagination) collection of [fields](#fields) for the given app.
|
||||
|
||||
## Path Parameters
|
||||
|
||||
{% table %}
|
||||
|
||||
- Property Name
|
||||
- Data Type
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- appId
|
||||
- `number`
|
||||
- The id of the app to retrieve fields for.
|
||||
|
||||
{% /table %}
|
||||
|
||||
## Query Parameters
|
||||
|
||||
**Note:** [Pagination](#pagination) query parameters can be used to control the number of fields returned in the response.
|
||||
|
||||
@@ -15,8 +15,9 @@ var onspringClient = new OnspringClient(
|
||||
config.ApiKey
|
||||
);
|
||||
|
||||
var getFieldsResponse = await onspringClient.GetFieldsForAppAsync(195);
|
||||
foreach (Field field in getFieldsResponse.Value.Items)
|
||||
var response = await onspringClient.GetFieldsForAppAsync(195);
|
||||
|
||||
foreach (var field in response.Value.Items)
|
||||
{
|
||||
Console.WriteLine($"{field.Id}, {field.AppId}, {field.Name}, {field.Type}, {field.Status}, {field.IsRequired}, {field.IsUnique}");
|
||||
}
|
||||
@@ -51,7 +52,6 @@ key = cfg['prod']['key']
|
||||
url = cfg['prod']['url']
|
||||
|
||||
client = OnspringClient(url, key)
|
||||
|
||||
response = client.GetFieldsByAppId(appId=195)
|
||||
|
||||
print(f'Status Code: {response.statusCode}')
|
||||
|
||||
Reference in New Issue
Block a user