I’m trying to pull my gas consumption data from my Octopus account using their API but am getting a 401 error response and no data. However, if I paste the URL into a browser then I get the data returned as expected.
The URL is:
The response in the HTTP monitor is:
HTTP/1.1 401 Unauthorized\r\nDate: Tue, 05 Mar 2024 10:31:10 GMT\r\nContent-Type: application/json\r\nContent-Length: 58\r\nConnection: close\r\nSet-Cookie: AWSALB=Y8DXEH7Hv9G9FsifBJdAEbACLcP8GWJhEW1Vpq97+OX0Y9vofs74UHK+l3z/9Z7Qx5/BYNNrrew86Wk161XbpNFPe9FfvS0D3XlipFIhnW3SBA55ZU3+g0DY+fk0; Expires=Tue, 12 Mar 2024 10:31:10 GMT; Path=/\r\nSet-Cookie: AWSALBCORS=Y8DXEH7Hv9G9FsifBJdAEbACLcP8GWJhEW1Vpq97+OX0Y9vofs74UHK+l3z/9Z7Qx5/BYNNrrew86Wk161XbpNFPe9FfvS0D3XlipFIhnW3SBA55ZU3+g0DY+fk0; Expires=Tue, 12 Mar 2024 10:31:10 GM...
--
You received this message because you are subscribed to the Google Groups "Loxone English" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loxone-englis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loxone-english/47b43cd1-8d41-4323-b2a0-c71c6ad53b68n%40googlegroups.com.
This is the http request in the monitor:
GET /v1/gas-meter-points/[MPRN]/meters/[METERSERIALNO]/consumption/?api_key=[My_Octopus_API_key] HTTP/1.1\r\nHost: api.octopus.energy\r\nUser-Agent: [en]\r\nConnection: close
and this is the curl result (although this too has failed, unlike when I use Chrome!!) which seems odd:
* Trying 54.77.136.51:443...
* Connected to api.octopus.energy (54.77.136.51) port 443
* schannel: disabled automatic use of client certificate
* ALPN: curl offers http/1.1
* ALPN: server accepted http/1.1
* using HTTP/1.1
> GET /v1/gas-meter-points/[MPRN]/meters/[METERSERIALNO]/consumption/?api_key=[My_Octopus_API_key] HTTP/1.1
> Host: api.octopus.energy
> User-Agent: curl/8.4.0
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Date: Tue, 05 Mar 2024 11:45:24 GMT
< Content-Type: application/json
< Content-Length: 58
< Connection: keep-alive
< Set-Cookie: AWSALB=6nxAjmmIfu9O1Eugtl3rJK7fT/NJjy+1FZsIXv85T5z0E/P/XY+mfX5zM/IELUoBTGU+6TimOlKb8tK1a2IX9Sv8A0fIHc3JgufckAav1M1ElId+wVXsKZL0OdIA; Expires=Tue, 12 Mar 2024 11:45:24 GMT; Path=/
< Set-Cookie: AWSALBCORS=6nxAjmmIfu9O1Eugtl3rJK7fT/NJjy+1FZsIXv85T5z0E/P/XY+mfX5zM/IELUoBTGU+6TimOlKb8tK1a2IX9Sv8A0fIHc3JgufckAav1M1ElId+wVXsKZL0OdIA; Expires=Tue, 12 Mar 2024 11:45:24 GMT; Path=/; SameSite=None; Secure
< Server: nginx
< WWW-Authenticate: Basic realm="api"
< Allow: GET, HEAD, OPTIONS
< X-Kraken-Correlation-ID: 1-65e705d4-68d041a368c05e415a331f91
< Strict-Transport-Security: max-age=31536000
< X-Content-Type-Options: nosniff
< Referrer-Policy: same-origin
< Cross-Origin-Opener-Policy: same-origin
< X-Frame-Options: SAMEORIGIN
< Vary: Accept-Language, Cookie, origin
< Content-Language: en-gb
<
{"detail":"Authentication credentials were not provided."}* Connection #0 to host api.octopus.energy left intact
To view this discussion on the web visit https://groups.google.com/d/msgid/loxone-english/0d37ce2e-03c0-4244-9247-b2fb10c12908n%40googlegroups.com.
Download failed
---------------------------
Failed to retrieve data from 'https://[MY-API-KEY]:@api.octopus.energy/v1/gas-meter-points/[MPRN]/meters/[METERSERIALNO]/consumption/' (Status code: 401)
See HTTP monitor for more information.
---------------------------
yet the http monitor shows success....!!!!
To view this discussion on the web visit https://groups.google.com/d/msgid/loxone-english/14ca6950-ec72-4f4a-b664-da00049fd9abn%40googlegroups.com.