Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following request carries two data fields, each contains a key value pair, together they deliver the authentification credentials.

Code Block
languagebash
themeEmacs
curl -c cfile \
	 -s \
	 -X POST 'https://sandbox.sensor.awi.de/rest/sensors/contacts/login'\
	 -o /dev/null \
	 -d 'username=<yourUserName>' \
	 -d 'authPassword=yourSecretPassword'

The cfile looks like this:

Code Block
languagebash
themeEmacs
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

sandbox.sensor.awi.de	FALSE	/sensorManagement-web	FALSE	0	JSESSIONID	RaCR4vWoHo7xKn92ohy2izuxjldw68olmHDjhA0.frame-test1
.awi.de	TRUE	/	FALSE	1670407206	x-auth-token	af9d8dce8jalf78271057345p5444022

...

and can be removed after successful operation by

Code Block
languagebash
themeEmacs
rm -v cfile

...

HTTP requests

GET

This gets basic information about an item.

Code Block
languagebash
themeEmacs
curl -X GET 'https://sandbox.sensor.awi.de/rest/sensors/item/getItem/456'

...

or nicely parsed (because piped into jq):


Code Block
languagebash
themeEmacs
curl -X GET 'https://sandbox.sensor.awi.de/rest/sensors/item/getItem/456' | jq .

...

PUT

You need proper privileges to modify items.

...

  • -b: a submitted cookie (remember the login cfile?)
  • -X: which type of http request is performed, in this case PUT
  • -H: header for the request, in this case
    • the content is json format
    • json format shall be accepted
  • -d: introduces a data field that is submitted along the PUT request, this is literally the submitted json
Code Block
languagebash
themeEmacs
curl -b cfile \
	 -X PUT 'https://sandbox.sensor.awi.de/rest/sensors/item/createItem' \
	 -H 'Content-Type: application/json' \
	 -H 'Accept: application/json' \
	 -d '{"description": "string", "shortName": "testnastring" , "longName": "string" , "serialNumber": "string" , "manufacturer": "string" , "parentID": 0 , "applicationTypeID": 0 , "model": "string" , "inventoryNumber": "string" , "itemStatusID": 2 , "itemTypeID": 110 , "id": 0 }'

...

  • "description": string --> for the overview tab
  • "shortName": string --> for the overview tab
  • "longName": string --> for the overview tab
  • "serialNumber": string --> for the overview tab
  • "manufacturer": string --> for the overview tab
  • "parentID": integer --> left blank if item should be parentless, otherwise enter numeric id of parental item (think about access rights for the parent, too)
  • "applicationTypeID": ignore
  • "model": string --> for the overview tab
  • "inventoryNumber": string --> for the overview tab
  • "itemStatusID": integer --> either know the necessary id or ask https://sandbox.sensor.awi.de/rest/sensors/item/getAllItemStatuses, in this case 2 refers to construction
  • "itemTypeID": integer --> either know the necessary id or ask https://sandbox.sensor.awi.de/rest/sensors/item/getAllItemCategories, in this case 110 is a sediment_grab
  • "id": integer --> set 0, since the item is supposed to be completly new

...

  • -b: locally stored cookie file
  • -X: which type of http request is performed, in this case DELETE
  • -H: header
Code Block
languagebash
themeEmacs
curl -b cfile \
	 -X DELETE \
	 -H 'Accept: application/json' \
	 'https://sandbox.sensor.awi.de/rest/sensors/contacts/deleteContactFromDevice/10877/80/29'

...

  • 10877: the item ID
  • 80: the user ID
  • 29: the contact role ID

...