@@ -22,7 +22,7 @@ The tutorial uses [cUrl](https://ec.haxx.se/) commands throughout, but is also a
2222[ Postman documentation] ( https://fiware.github.io/tutorials.Context-Providers/ngsi-ld.html )
2323
2424[ ![ Run in Postman] ( https://run.pstmn.io/button.svg )] ( https://app.getpostman.com/run-collection/2c53b7c2bce9fd7b7b47 )
25- [ ![ Open in GitHub Codespaces] ( https://github.com/codespaces/badge.svg )] ( https://github.com/codespaces/new?repo=FIWARE/tutorials.LD-Subscriptions-Registrations/tree/ NGSI-LD )
25+ [ ![ Open in GitHub Codespaces] ( https://github.com/codespaces/badge.svg )] ( https://github.com/codespaces/new?repo=FIWARE/tutorials.LD-Subscriptions-Registrations&ref= NGSI-LD )
2626
2727## Contents
2828
@@ -284,9 +284,13 @@ Animals are not available on the default tenant, Data about animals on the farm
284284#### 1️⃣ Request:
285285
286286```console
287- curl -L 'http://localhost:1027/ngsi-ld/v1/entities/?type=Animal&limit=100&options=concise' \
288- -H 'Content-Type: application/json' \
289- -H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
287+ curl -G -X GET \
288+ 'http://localhost:1027/ngsi-ld/v1/entities' \
289+ -H 'Content-Type: application/json' \
290+ -H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
291+ -d 'format=Animal' \
292+ -d 'limit=100' \
293+ -d 'format=concise'
290294```
291295
292296#### Response:
@@ -319,9 +323,13 @@ The response on port `1027` consists of the details of the **Animal** entities h
319323#### 2️⃣ Request:
320324
321325```console
322- curl -L 'http://localhost:1026/ngsi-ld/v1/entities/?type=Animal&limit=100&options=concise' \
323- -H 'Content-Type: application/json' \
324- -H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
326+ curl -G -X GET \
327+ 'http://localhost:1026/ngsi-ld/v1/entities' \
328+ -H 'Content-Type: application/json' \
329+ -H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
330+ -d 'format=Animal' \
331+ -d 'limit=100' \
332+ -d 'format=concise'
325333```
326334
327335#### Response:
@@ -358,7 +366,8 @@ but no data is held in the primary context broker whatsoever.
358366#### 3️⃣ Request:
359367
360368```console
361- curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
369+ curl -X POST \
370+ 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
362371-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
363372-H 'Content-Type: application/json' \
364373-d '{
@@ -390,9 +399,13 @@ animals from the farmer subsystem:
390399#### 4️⃣ Request:
391400
392401```console
393- curl -L 'http://localhost:1026/ngsi-ld/v1/entities/?type=Animal&limit=100&options=concise' \
394- -H 'Content-Type: application/json' \
395- -H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
402+ curl -G -X GET \
403+ 'http://localhost:1026/ngsi-ld/v1/entities' \
404+ -H 'Content-Type: application/json' \
405+ -H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
406+ -d 'format=Animal' \
407+ -d 'limit=100' \
408+ -d 'format=concise'
396409```
397410
398411#### Response:
@@ -434,8 +447,10 @@ by the associated `@context` file.
434447#### 5️⃣ Request:
435448
436449```console
437- curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/?type=Animal' \
438- -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
450+ curl -G -X GET \
451+ 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
452+ -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
453+ -d 'type=Animal'
439454```
440455
441456#### Response:
@@ -503,7 +518,7 @@ curl -G -X GET \
503518 'http://localhost:1030/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
504519-H 'Content-Type: application/json' \
505520-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
506- -d 'attrs= name,comment'
521+ -d 'pick=id,type, name,comment'
507522```
508523
509524#### Response:
@@ -528,7 +543,8 @@ own broker and the vet:
528543#### 7️⃣ Request:
529544
530545```console
531- curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
546+ curl -X POST \
547+ 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
532548-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
533549-H 'NGSILD-Tenant: farmer' \
534550-H 'Content-Type: application/json' \
@@ -676,7 +692,7 @@ curl -G -X GET \
676692 -H 'Accept: application/json' \
677693 -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
678694 -H 'NGSILD-Tenant: contractor' \
679- -d 'attrs= name%2Ccomment '
695+ -d 'pick=id,type, name,comment '
680696```
681697
682698#### Response:
@@ -734,7 +750,7 @@ curl -G -X GET \
734750 -H 'Accept: application/json' \
735751 -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
736752 -H 'NGSILD-Tenant: farmer' \
737- -d 'attrs= name%2Ccomment '
753+ -d 'pick=id,type, name,comment '
738754```
739755
740756#### Response:
@@ -776,7 +792,8 @@ The result of a `exclusive` registration is that no data for the registered attr
776792Consider for example an Animal collar which supplies data for the entity `urn:ngsi-ld:Animal:cow001` - this is likely to be a device attached to an IoT Agent. The underlying device protocol and payload doesn't matter, since we are able to make an NGSI-LD request to the IoT Agent which then requests information from the device itself:
777793
778794```console
779- curl -L 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
795+ curl -X GET \
796+ 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
780797 -H 'Accept: application/json' \
781798 -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
782799 -H 'NGSILD-Tenant: openiot'
@@ -822,7 +839,8 @@ The response shows the live readings from the device itself.
822839An exclusive registration can be made on the **Farmer** context broker to always receive **live** information from the IoT Agent. The `mode` is set to `"exclusive"`, and since the IoT Agent is only accepting **GET** requests the `"operations` attribute is set to `"retrieveOps"` only. A fixed `contextSourceInfo` can be used if the endpoint does not understand JSON-LD expansion/compaction.
823840
824841```console
825- curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
842+ curl -X POST \
843+ 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
826844 -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
827845 -H 'NGSILD-Tenant: farmer' \
828846 -H 'Content-Type: application/json' \
@@ -861,10 +879,11 @@ curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
861879The **farmer** context broker is now able to get the `location` and `heartRate` of `urn:ngsi-ld:Device:cow001`
862880
863881```console
864- curl -L 'http://localhost:1027/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001?attrs=location%2CheartRate ' \
882+ curl -G -X 'http://localhost:1027/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
865883 -H 'Accept: application/json' \
866884 -H 'NGSILD-Tenant: farmer' \
867- -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
885+ -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
886+ -d 'pick=id,type,location,heartRate'
868887```
869888
870889#### Response:
@@ -903,7 +922,8 @@ curl -L 'http://localhost:1027/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001?att
903922Note that an attempt by the Farmer to directly update the `location` or `heartRate` attributes will **fail** with **409 - Conflict** as an exclusive registration prohibits this:
904923
905924```console
906- curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
925+ curl -L -X PATCH \
926+ 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
907927 -H 'Accept: application/ld+json' \
908928 -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
909929 -H 'NGSILD-Tenant: farmer' \
@@ -944,10 +964,11 @@ of fields. In some cases you already have a temperature gauge in a field and you
944964To find the **AgriParcel** `temperature` data currently available to the **farmer**, make a request to the `/entities` endpoint and supply the `type` parameter.
945965
946966```console
947- curl -L 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel&attrs=temperature ' \
967+ curl -G -X 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel' \
948968 -H 'Accept: application/json' \
949969 -H 'NGSILD-Tenant: farmer' \
950- -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
970+ -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
971+ -d 'pick=id,type,temperature'
951972```
952973
953974#### Response:
@@ -974,10 +995,11 @@ Initially only one AgriParcel is returned, since it is the only one which the **
974995Make the same request directly to the **Weather** context broker to obtain the information known to the Weather forecaster:
975996
976997```console
977- curl -L 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel&attrs=temperature ' \
998+ curl -G -X 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel' \
978999 -H 'Accept: application/json' \
9791000 -H 'NGSILD-Tenant: weather' \
980- -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
1001+ -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
1002+ -d 'pick=id,type,temperature'
9811003```
9821004
9831005#### Response:
@@ -1026,7 +1048,8 @@ The weather forecast context broker has more information and its values have a m
10261048An auxiliary registration can be made on the **Farmer** context broker to only receive **live** information from the weather forecaster if it does not hold information locally. The `mode` is set to `"auxilary"`, and since the IoT Agent is only accepting **GET** requests the `"operations` attribute is set to `"retrieveOps"` only.
10271049
10281050```console
1029- curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
1051+ curl -X POST \
1052+ 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
10301053 -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
10311054 -H 'NGSILD-Tenant: farmer' \
10321055 -H 'Content-Type: application/json' \
@@ -1056,10 +1079,11 @@ curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
10561079Once the registration has been created, the farmer can request for `temperature` data once again.
10571080
10581081```console
1059- curl -L 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel&attrs=temperature ' \
1082+ curl -G -X 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel' \
10601083 -H 'Accept: application/json' \
10611084 -H 'NGSILD-Tenant: farmer' \
1062- -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
1085+ -H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
1086+ -d 'pick=id,type,temperature'
10631087```
10641088
10651089#### Response:
0 commit comments