Resource Update API Documentation
This API enables partial updates to resources using a structured JSON format. The format is inspired by JSON Patch Operations, allowing precise modifications to both objects and lists. If any operation in the array fails, no changes are applied to the resource
Operations
Operations | Applicable to | Description |
---|---|---|
Replace |
Objects | Replaces the value at the specified path with a new value. Null to reset path |
Add |
Lists | Adds a new element to a list at the specified index |
Remove |
Lists | Removes an element from a list at the specified index |
Payload Structure
The payload consists of an array of operations to be applied to the resource.
JSON Pointer Paths
The path field follows the JSON Pointer syntax to specify the location of elements within the resource.
Discovery
To discover the available attributes for a specific resource type and understand the validations applied to each attribute, you can call the following API:
curl -X GET "https://api-v2.wogeez.com/resources/DEVICE/" \
-H "Authorization: Bearer your-jwt-token" \
-H "Accept: application/json"
{
"items": [
{
"path": "/name",
"operations": [
"Replace"
],
"validators": [
"must not null",
"length must be between 3 and 100"
]
},
{
"path": "/payload/location/name",
"operations": [
"Replace"
],
"validators": [
"length must be between 1 and 200"
]
},
{
"path": "/payload/location/description",
"operations": [
"Replace"
],
"validators": [
"length must be between 1 and 4000"
]
},
{
"path": "/payload/geoLocation/latitude",
"operations": [
"Replace"
],
"validators": [
"must be a float"
]
},
{
"path": "/payload/geoLocation/longitude",
"operations": [
"Replace"
],
"validators": [
"must be a float"
]
},
{
"path": "/payload/geoLocation/altitude",
"operations": [
"Replace"
],
"validators": [
"must be a float"
]
}
]
}
curl -X 'PATCH' \
'https://api-v2.wogeez.com/resources/companies/YOUR_COMPANY_ID/resources/YOUR_RESOURCE_ID' \
-H 'accept: */*' \
-H 'Authorization: Bearer your-jwt-token' \
-H 'Content-Type: application/json' \
-d '{
"operations": [
{
"operation": "Replace",
"path": "/name",
"value": "No"
},
{
"operation": "Replace",
"path": "/payload/location/name",
"value": "Centre Commercial de Lille"
},
{
"operation": "Replace",
"path": "/payload/geoLocation/altitude",
"value": null
},
{
"operation": "Replace",
"path": "/payload/geoLocation/latitude",
"value": null
},
{
"operation": "Replace",
"path": "/payload/geoLocation/longitude",
"value": null
},
{
"operation": "Replace",
"path": "/payload/location/description",
"value": "Cette borne est localisée sur l'\''emplacement 23 du centre commercial, vous pouvez appeler la sécurité pour plus d'\''informations"
}
]
}'
Error Handling in Resource Update API
When an error occurs during the processing of a request, the API returns a detailed error response to help identify the issue. Below is an example of the error format and an explanation of its fields.
{
"code": "BAD_REQUEST",
"message": "Bad Request",
"reason": "Invalid patch, see reasons field",
"reasons": [
"/name - Replace - length must be between 3 and 100"
]
}
Warning
In the Resource Update API, both the path and operation fields are case-sensitive, meaning that they must exactly match the expected format and capitalization. Failing to follow this rule can result in errors.