During this tutorial: https://github.com/telefonicaid/iotagent-json/blob/master/docs/stepbystep.md
When I execute the curl:
curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Fiware-Service: myHome" -H "Fiware-ServicePath: /environment" -H "Cache-Control: no-cache" -d '{
"value" : "300"
}' 'http://localhost:1026/v1/contextEntities/LivingRoomSensor/attrs/sleepTime'
I'm getting this error response:
{
"orionError" : {
"code" : "400",
"reasonPhrase" : "Bad Request",
"details" : "service not found"
}
}
How to fix this?
Cumps
It seems you are "mixing" URL styles from NGSIv1 and NGSIv2 :) I mean, it should be either:
/v2/entities/LivingRoomSensor/attrs/sleepTime
or
/v1/contextEntities/LivingRoomSensor/attributes/sleepTime
My recomendation is always to use NGSIv2, as it is a more powerfull, flexible and simple version of the context management API that Orion Context Broker provides.
Solved by changing:
localhost:1026/v1/contextEntities/LivingRoomSensor/attrs/…
to
localhost:1026/v1/contextEntities/LivingRoomSensor/attributes/…
Related
I'd like to create a custom link via the API, that's to say instead of maclede12.co/3R8OeCm maclede12.co/magnifique. It is also referred as custom back-half.
I'm able to patch a link with the API via this request:
curl \
-H 'Authorization: Bearer token' \
-H 'Content-Type: application/json' \
-X PATCH \
-d '{
"id": "maclede12.co/3R8OeCm",
"custom_bitlinks": [
"maclede12.co/magnifique"
],
"tags": [
"bitly",
"api"
]
}' \
https://api-ssl.bitly.com/v4/bitlinks/maclede12.co/3R8OeCm
The tags are updated but I'm not able to get a custom link. The custom_bitlinks parameter comes from the doc but is it still even possible to do it?
Let assume we have an entity corresponding to an IoT controller device, let say a door controller.
We want to define an event that could cause an action (open/close). So we need to send a command to this device.
How would we make this happen? Add an attribute in the entity like for example setDoorStatus that can be written to via the NGSI API? And then have some IoT agent or command handler subscribe to this attribute?
Is there any example of a Data Model where this is done?
The easiest way to do this is to provision a device using any IoT Agent. IoT Agents have a standard API for device provisioning, where commands can be listed:
curl -L -X POST 'http://localhost:4041/iot/devices' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
--data-raw '{
"devices": [
{
"device_id": "door001",
"entity_name": "urn:ngsi-ld:Door:001",
"entity_type": "Door",
"protocol": "PDI-IoTA-UltraLight",
"transport": "HTTP",
"endpoint": "http://context-provider:3001/iot/door001",
"commands": [
{"name": "unlock","type": "command"},
{"name": "open","type": "command"},
{"name": "close","type": "command"},
{"name": "lock","type": "command"}
],
"attributes": [
{"object_id": "s", "name": "state", "type":"Text"}
],
"static_attributes": [
{"name":"refStore", "type": "Relationship","value": "urn:ngsi-ld:Store:001"}
]
}
]
}
'
The IoT Agent node library defines a command paradigm for actuating devices through commands
In this case you have an attribute open which is registered on a context broker as coming from a device and you can actuate the device using the following request:
NGSI-v2
curl -L -X PATCH 'http://localhost:1026/v2/entities/urn:ngsi-ld:Door:001/attrs' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
--data-raw '{
"open": {
"type" : "command",
"value" : ""
}
}'
NSGI-LD
curl -L -X PATCH 'http://localhost:4041/ngsi-ld/v1/entities/urn:ngsi-ld:Device:door001/attrs/open' \
-H 'NGSILD-Tenant: openiot' \
-H 'NGSILD-Path: /' \
-H 'Content-Type: application/json' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--data-raw '{
"type": "Property",
"value": ""
}'
The relevant IoT Agent accepts the request and passes it down to the device using the appropriate device syntax. Once activated, additional special status and info attributes are added to the entity as soon as it has any information of the command progress.
Full examples can be found within the FIWARE Tutorials:
NGSI-v2
NGSI-LD
Hello I want to use the API approach to show the jenkins build status with curl as stated here: https://developer.atlassian.com/server/bitbucket/how-tos/updating-build-status-for-commits/
Assembled that:
curl -u username:'password' -H "Content-Type: application/json" -X POST https://tools.my.repo.com/bitbucket/rest/build-status/1.0/commits/620d293ed88412e45c58aae537b8765be2e8d148 -d #build0.json`
Where my build json contains:
{
"state": "SUCCESSFUL",
"key": "8",
"name": "feature/branch",
"url": "https://my.jenkins.placeholder/job/Plugintest/",
"description": "Changes by Umbert Eco"
}
I need to have that in one line...Is it possible?
Yes!! Try framing the curl in this way
curl -u username:password -H "Content-Type: application/json" -X POST https://tools.my.repo.com/bitbucket/rest/build-status/1.0/commits/620d293ed88412e45c58aae537b8765be2e8d148 -d '{\"state\": \"SUCCESSFUL\",\"key\": \"8\",\"name\": \"feature/branch\",\"url\": \"https://my.jenkins.placeholder/job/Plugintest\",\"description\": \"Changes by Umbert Eco\"}'
orion version : 2.3.0
iotagent-ul version : 1.12.0
I am using fiware and iotagent over mqtt. I want to send commands to some devices with different values. I have followed https://github.com/FIWARE/tutorials.IoT-over-MQTT and read some documentation.
After provisionning a service group (with apikey: 123456) and an actuator, I can send commands with values by following the iota URL :
curl -iX POST \
'http://localhost:4041/iot/devices' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"devices": [
{
"device_id": "dev001",
"entity_name": "urn:ngsi-ld:Device:001",
"entity_type": "Device",
"protocol": "PDI-IoTA-UltraLight",
"transport": "MQTT",
"commands": [
{"name": "date","type": "command", "value": {"hour": 9, "minute": 31, "second": 0}}
]
}
]
}
'
iota publish a mqtt message to : /123456/dev001/cmd with payload dev001#date|hour=9|minute=31|second=0
But when using the context broker, the value is ignored :
curl -iX PATCH \
'http://localhost:1026/v2/entities/urn:ngsi-ld:Device:001/attrs' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"date": {
"type" : "command",
"value" : {"hour": 9, "minute": 31, "second": 0}
}
}'
Here, iota publish a mqtt message to : /123456/dev001/cmd with payload dev001#date|
Why is it ignored ? Am I doing somthing wrong ?
sorry for my poor english.
I found a solution... adding the type in the url make the context take account of the value... weird.
The final url must be :
curl -iX PATCH \
'http://localhost:1026/v2/entities/urn:ngsi-ld:Device:001/attrs?type=Device' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"date": {
"type" : "command",
"value" : {"hour": 9, "minute": 31, "second": 0}
}
}'
EDIT:
knowing the solution, I have tried to understand the problem and found this issue : https://github.com/telefonicaid/fiware-orion/issues/3647
According to CPrs and request forwarding documentation
On forwarding, any type of entity in the NGSIv2 update/query matches
registrations without entity type. However, the opposite doesn't work,
so if you have registrations with types, then you must use ?type in
NGSIv2 update/query in order to obtain a match. Otherwise you may
encounter problems, like the one described in this post at
StackOverflow.
EDIT 2:
This is a duplicate of : Orion CB doesn't update lazy attributes on IoT Agent
Is it possible to use the Global Instance of Keystone to retrieve registered user profile info?
According to these references: https://github.com/telefonicaid/fiware-pep-steelskin#keystone and Keystone create user and permissions by api, it seems possible if I wish to install an instance by my own. However, what if I wish to use the Global Instance, instead. Is it possible?
For example, I have tested te retrieve some data as indicated below without success:
curl -s -H "X-Auth-Token:cXylpiNyh74V6J9YOlqN2GTzYSmGQa" http://cloud.lab.fiware.org:4730/v2.0/tokens | python -mjson.tool
curl -s -H "X-Auth-Token:cXylpiNyh74V6J9YOlqN2GTzYSmGQa" http://cloud.lab.fiware.org:4730/v3/users/ | python -mjson.tool
curl http://cloud.lab.fiware.org:4730/v3/auth/tokens -H "Content-Type: application/json" -d ' { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "domain": { "name": "matest" }, "name": "pep_proxy_99c59...", "password": "e3025a286dab..." } } } } }'
Note: I have tried both port: 5000 and 4730.
Any hint will be appreciated.
Users doesn't have permissions to see other users information or to create new users using the API.
However, you can issue tokens from the global keystone using both v2.0 and v3 protocols:
curl -X POST http://130.206.84.8:4730/v2.0/tokens \
-H 'Content-Type: application/json' \
-d "{\"auth\": {\"tenantName\": \"${OS_TENANT_NAME}\",
\"passwordCredentials\": {
\"username\": \"$OS_USERNAME\",
\"password\": \"$OS_PASSWORD\"}}}" | \
jq -r '.access.token.id'
Or issue a token in v3:
curl -v -H "Content-Type: application/json" -d "
{ \"auth\": {
\"identity\": {
\"methods\": [\"password\"],
\"password\": {
\"user\": {
\"name\": \"$OS_USERNAME\",
\"domain\": { \"id\": \"default\" },
\"password\": \"$OS_PASSWORD\"
}
}
}
}
}" http://cloud.lab.fiware.org:4730/v3/auth/tokens 2>&1 \
| grep -i "X-Subject-Token"
There are few things you can do with Keystone itself using these tokens if you are not the admin user (Non admin users obviously have few permissions). However, you coud, for instance query the endpoints:
curl -s -H "X-Auth-Token: $TOKEN_ID" http://130.206.84.8:4730/v3/endpoints
The domains:
curl -s -H "X-Auth-Token: $TOKEN_ID" http://130.206.84.8:4730/v3/domains