From 153ad23622e729e6af0d1ee154e5af4deb6cdba1 Mon Sep 17 00:00:00 2001 From: pkel-kn Date: Tue, 14 May 2024 08:17:30 +0200 Subject: [PATCH] Update walkthrough_apiv2.md Consistent syntax highlighting in API walkthrough --- doc/manuals/user/walkthrough_apiv2.md | 120 +++++++++++++------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/doc/manuals/user/walkthrough_apiv2.md b/doc/manuals/user/walkthrough_apiv2.md index 568b208a7f..7268a838c2 100644 --- a/doc/manuals/user/walkthrough_apiv2.md +++ b/doc/manuals/user/walkthrough_apiv2.md @@ -117,10 +117,10 @@ host and/or port can be specified) and echoes whatever it receives in the terminal window where it is executed. Run it using the following command: -``` -# cd /dir/where/accumulator-server/is/downloaded -# chmod a+x accumulator-server.py -# ./accumulator-server.py --port 1028 --url /accumulate --host ::1 --pretty-print -v +```shell +cd /dir/where/accumulator-server/is/downloaded +chmod a+x accumulator-server.py +./accumulator-server.py --port 1028 --url /accumulate --host ::1 --pretty-print -v ``` Note this script requires Flask version 2.0.2 (along with Werkzeug 2.0.2) and paho-mqtt version 1.6.1, which can be installed using @@ -148,7 +148,7 @@ following: - For POST: -``` +```shell curl localhost:1026/ -s -S [headers] -d @- < -s -S [headers] -X PUT -d @- < -s -S [headers] -X PATCH -d @- < -s -S [headers] ``` - For DELETE: -``` +```shell curl localhost:1026/ -s -S [headers] -X DELETE ``` @@ -187,14 +187,14 @@ Regarding \[headers\] you have to include the following ones: - Accept header to specify the payload format in which you want to receive the response. You should explicitly specify JSON. -``` +```shell curl ... -H 'Accept: application/json' ... ``` - If using payload in the request (i.e. POST, PUT or PATCH), you have to supply the `Context-Type` HTTP header to specify the format (JSON). -``` +```shell curl ... -H 'Content-Type: application/json' ... ``` @@ -214,7 +214,7 @@ Some additional remarks: `python` by the particular Python executable in your case (e.g. in some cases it could be `| python3 -mjson.tool`). -``` +```shell (curl ... | python -mjson.tool) <22' -s -S -H 'Accept: application/json' | python -mjson.tool ``` @@ -565,7 +565,7 @@ source of context information. Let's assume that this application in a given moment wants to set the temperature and pressure of Room1 to 26.5 ºC and 763 mmHg respectively, so it issues the following request: -``` +```shell curl localhost:1026/v2/entities/Room1/attrs -s -S -H 'Content-Type: application/json' -X PATCH -d @- <