• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get host MAC via REST API inside container
#5
Hi all,

the approach to calculate the MAC address from the CPU serial number and the Raspberry OUI would be a possibilty. But since we want to communicate with the Hilscher API anyway, we decided to read the MAC address from the API as well.

Here is a short explanation of how we could use the API. Maybe it helps someone who is facing a similar problem.

Our problem with the network settings request was that we not expected that the last part of the path "LANSettings" is case sensitiv.
And also the category parameter (?category=LAN) is mandatory.
This request now works:
Code:
curl -k -X GET 'https://<HOST>:443/get/networksettings/LANSettings?category=LAN' -H 'Cookie: <AUTH-COOKIE>'

Another problem we faced while integrating the API in our application was the login.
From the following request you could extract the retrieved authentication cookie:
Code:
curl -v -k -X POST 'https://<HOST>:443/login' -H 'Content-Type: application/json' -d '{"username":<USER>,"password":<PASSWORD>}'
The response status code is "302 - Found". This is a redirection status code, so the many high level HTTP frameworks follow the redirects by default.
But if you follow the redirects the authentication cookie is no longer valid.
If we use the following request for logging in (with the -L option), the retrieved cookie is not valid:
Code:
curl -L -v -k -X POST 'https://<HOST>:443/login' -H 'Content-Type: application/json' -d '{"username":<USER>,"password":<PASSWORD>}'
So we have to make sure, that the automatic following of redirects is disabled for the login.

Best regards,
Benjamin
  Reply


Messages In This Thread
Get host MAC via REST API inside container - by bschandra - October-14th-2020, 01:30 PM
RE: Get host MAC via REST API inside container - by bschandra - November-16th-2020, 09:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  REST API server data communication MGharat 2 3,150 July-21st-2021, 07:01 AM
Last Post: MGharat
  TOSILOCK for CONTAINER COswald 3 3,099 July-13th-2021, 11:32 AM
Last Post: Armin@netPI
  Accessing netPI web UI with REST API Armin@netPI 14 10,624 June-30th-2021, 05:06 AM
Last Post: Armin@netPI
  Access to RTC from my own container application tad 1 4,199 March-19th-2021, 02:58 PM
Last Post: Armin@netPI
  [SOLVED] Starting services/commands/scripts at startup of a container Jonas.Sellmann@outlook.de 9 8,245 March-9th-2021, 08:47 AM
Last Post: WalterSchaefer
  OpenVPN container Armin@netPI 0 2,104 January-3rd-2021, 12:13 PM
Last Post: Armin@netPI
  operating Console of a container on netPI connected to Wi-Fi tethering tad 3 3,478 December-3rd-2020, 12:32 PM
Last Post: tad
  NIOT-E-NPIX-4DI4DO with netpi-netx container WalterSchaefer 3 9,468 November-25th-2020, 01:06 PM
Last Post: zen89
  NPIX-4DI4DO and NetPi-Nodered container issues alhammi 4 10,797 November-16th-2020, 01:35 PM
Last Post: alhammi
  Exporting and importing container images Armin@netPI 3 4,039 May-20th-2020, 11:24 AM
Last Post: COswald

Forum Jump:


Users browsing this thread: 1 Guest(s)