Update an asset metadata.
curl --request PATCH \
--url https://lab.trustos.telefonicatech.com/track/v2/assets/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"metadata": {
"color": "blue",
"position": {
"x": "98.35",
"y": "-12.32"
}
}
}
'import requests
url = "https://lab.trustos.telefonicatech.com/track/v2/assets/{id}"
payload = { "metadata": {
"color": "blue",
"position": {
"x": "98.35",
"y": "-12.32"
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({metadata: {color: 'blue', position: {x: '98.35', y: '-12.32'}}})
};
fetch('https://lab.trustos.telefonicatech.com/track/v2/assets/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://lab.trustos.telefonicatech.com/track/v2/assets/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'metadata' => [
'color' => 'blue',
'position' => [
'x' => '98.35',
'y' => '-12.32'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://lab.trustos.telefonicatech.com/track/v2/assets/{id}"
payload := strings.NewReader("{\n \"metadata\": {\n \"color\": \"blue\",\n \"position\": {\n \"x\": \"98.35\",\n \"y\": \"-12.32\"\n }\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://lab.trustos.telefonicatech.com/track/v2/assets/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"color\": \"blue\",\n \"position\": {\n \"x\": \"98.35\",\n \"y\": \"-12.32\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://lab.trustos.telefonicatech.com/track/v2/assets/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"metadata\": {\n \"color\": \"blue\",\n \"position\": {\n \"x\": \"98.35\",\n \"y\": \"-12.32\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 200,
"message": "Asset metadata updated",
"data": {
"trackID": "did:trustos:trackid:<id>",
"assetId": "asset-test-01",
"data": {
"id": "A2839RP",
"version": "1"
},
"networkId": 10004,
"assetHash": "6c253e352981fabaf6ba78a301cd116320010a13abe8abf8428eaedcee7ddabd",
"transactions": [
{
"metadata": {
"color": "red",
"position": {
"x": "23.34",
"y": "-24.22"
}
},
"timestamp": 1711538908,
"userOwner": "did:user:{issuer}",
"hash": "456fc02752e48108af8548b4544c3ab6deb30d091567cff0b5d69a3beda5678d",
"smartContract": "0xabcdbcbff5fa05e060e7dfe3e608cba010d11abc",
"transactionHash": "0x456dbcbff5fa05e060e7dfe3e608cba010d112c75ffbc6531a09b2a1351b3452"
}
]
}
}{
"statusCode": 400,
"type": "Validation Error",
"message": "Request parameters are wrong, check requirements",
"errors": [
{
"field": "",
"error": ""
}
]
}{
"statusCode": 401,
"type": "Authentication Error",
"message": "Token is not provided"
}{
"statusCode": 404,
"type": "Not Found Error",
"message": "Asset not found"
}{
"statusCode": 429,
"type": "Out of Credits Error",
"message": "User has run out of credits. Please, contact BTeam to increase the limit"
}{
"statusCode": 500,
"type": "Internal Server Error",
"message": "Oops! Something went wrong, please try again later"
}Asset Management
Update Asset
Updates the assets’s variable information in the metadata property.
PATCH
/
assets
/
{id}
Update an asset metadata.
curl --request PATCH \
--url https://lab.trustos.telefonicatech.com/track/v2/assets/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"metadata": {
"color": "blue",
"position": {
"x": "98.35",
"y": "-12.32"
}
}
}
'import requests
url = "https://lab.trustos.telefonicatech.com/track/v2/assets/{id}"
payload = { "metadata": {
"color": "blue",
"position": {
"x": "98.35",
"y": "-12.32"
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({metadata: {color: 'blue', position: {x: '98.35', y: '-12.32'}}})
};
fetch('https://lab.trustos.telefonicatech.com/track/v2/assets/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://lab.trustos.telefonicatech.com/track/v2/assets/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'metadata' => [
'color' => 'blue',
'position' => [
'x' => '98.35',
'y' => '-12.32'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://lab.trustos.telefonicatech.com/track/v2/assets/{id}"
payload := strings.NewReader("{\n \"metadata\": {\n \"color\": \"blue\",\n \"position\": {\n \"x\": \"98.35\",\n \"y\": \"-12.32\"\n }\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://lab.trustos.telefonicatech.com/track/v2/assets/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"color\": \"blue\",\n \"position\": {\n \"x\": \"98.35\",\n \"y\": \"-12.32\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://lab.trustos.telefonicatech.com/track/v2/assets/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"metadata\": {\n \"color\": \"blue\",\n \"position\": {\n \"x\": \"98.35\",\n \"y\": \"-12.32\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 200,
"message": "Asset metadata updated",
"data": {
"trackID": "did:trustos:trackid:<id>",
"assetId": "asset-test-01",
"data": {
"id": "A2839RP",
"version": "1"
},
"networkId": 10004,
"assetHash": "6c253e352981fabaf6ba78a301cd116320010a13abe8abf8428eaedcee7ddabd",
"transactions": [
{
"metadata": {
"color": "red",
"position": {
"x": "23.34",
"y": "-24.22"
}
},
"timestamp": 1711538908,
"userOwner": "did:user:{issuer}",
"hash": "456fc02752e48108af8548b4544c3ab6deb30d091567cff0b5d69a3beda5678d",
"smartContract": "0xabcdbcbff5fa05e060e7dfe3e608cba010d11abc",
"transactionHash": "0x456dbcbff5fa05e060e7dfe3e608cba010d112c75ffbc6531a09b2a1351b3452"
}
]
}
}{
"statusCode": 400,
"type": "Validation Error",
"message": "Request parameters are wrong, check requirements",
"errors": [
{
"field": "",
"error": ""
}
]
}{
"statusCode": 401,
"type": "Authentication Error",
"message": "Token is not provided"
}{
"statusCode": 404,
"type": "Not Found Error",
"message": "Asset not found"
}{
"statusCode": 429,
"type": "Out of Credits Error",
"message": "User has run out of credits. Please, contact BTeam to increase the limit"
}{
"statusCode": 500,
"type": "Internal Server Error",
"message": "Oops! Something went wrong, please try again later"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Identifier of the asset.
Example:
"did:trustos:trackid:<id>"
Body
application/json
Data needed for the update of an asset.
Metadata to be updated.
Example:
{
"color": "blue",
"position": { "x": "98.35", "y": "-12.32" }
}
Was this page helpful?
⌘I