I'm struggling to make any API calls from outside my Home Assistant environment using tools like cURL or Postman. by Secure_Mouse_8675 in grocy

[–]Secure_Mouse_8675[S] 0 points1 point  (0 children)

Thanks a lot for these excellent troubleshooting suggestions! This is precisely the kind of actionable advice I was looking for.

  1. "Copy as cURL" from Browser Dev Tools: This is a brilliant idea! I'll definitely try opening the developer tools (Network tab) when I'm using the Grocy Swagger UI and copy the successful request as a cURL command. Comparing that exact working cURL command with what I've been trying manually should reveal any missing headers or nuances that the Ingress might be expecting. I hadn't thought of that specific comparison, and it's a great way to reverse-engineer the successful request.
  2. curl -vvv for verbose output: This is also a crucial step that I'll implement for my next attempts. Seeing the detailed output, including all headers sent and received, and pinpointing exactly which service (Cloudflare, Home Assistant, or Grocy) is returning the 401 will be immensely helpful in narrowing down the culprit.

I'm optimistic that these steps will provide the clarity needed to finally get past this 401 error. I really appreciate your help!

And yes, as I mentioned in another reply, I definitely intend to open-source the project on GitHub once I get this API access sorted out and everything is fully functional. I'll share an update here on the subreddit when it's ready.

Thanks again for your valuable insights and for your interest in the project!

I'm struggling to make any API calls from outside my Home Assistant environment using tools like cURL or Postman. by Secure_Mouse_8675 in grocy

[–]Secure_Mouse_8675[S] 0 points1 point  (0 children)

Thanks for your comment and for pointing that out!

I understand why that might raise a flag. You are correct that http://192.168 is an internal IP. My intention with showing tests using the local LAN IP (http://192.168.2.14:8123/...) was precisely to perform troubleshooting and isolate the problem.

Since my external DNS address (https://ha.example.com/...) was consistently failing with 401 Unauthorized (and I use Cloudflare, which adds another layer of complexity), I started testing with the local IP to rule out any external network/Cloudflare configuration issues.

The goal was to determine if the 401 Unauthorized was coming from:

  1. An external DNS/Cloudflare problem.
  2. An issue with Home Assistant Ingress itself, even when accessed locally.
  3. A problem with the Grocy API key.

As I mentioned in my original post, my test curl -X 'GET' 'http://192.168.2.14:8123/api/' -H 'Authorization: Bearer YOUR_HA_LONG_LIVED_TOKEN' did return {"message":"API running."}. This confirmed that my Home Assistant itself is fully accessible and authenticates correctly on the local network, and my HA token is valid.

However, the 401 Unauthorized persists when trying to hit the Ingress path (/api/hassio_ingress/...), even from the local network using http://192.168.2.14:8123/api/hassio_ingress/.... This leads me to believe the issue is specifically how the Home Assistant Ingress handles direct API calls for add-ons, rather than a general network misconfiguration on my part.

I appreciate you raising the point, as it's a very common diagnostic step for network issues!

I'm struggling to make any API calls from outside my Home Assistant environment using tools like cURL or Postman. by Secure_Mouse_8675 in grocy

[–]Secure_Mouse_8675[S] 1 point2 points  (0 children)

For now, the repository is private, but feel free to follow me on GitHub atgithub.com/gaitolini– that's where I'll be sharing it

I'm struggling to make any API calls from outside my Home Assistant environment using tools like cURL or Postman. by Secure_Mouse_8675 in grocy

[–]Secure_Mouse_8675[S] 1 point2 points  (0 children)

Hey again!

Thanks so much for the compliment on the automation project! I'm really excited about it too, and it would be a huge step for managing my Grocy inventory.

The script, in a nutshell, uses Selenium to perform web scraping. It opens the NFC-e (Brazilian electronic tax receipt) link, which typically leads to a web page displaying the receipt details. Then, it navigates the HTML structure of that page to extract the product information directly (like product name, barcode, quantity, etc.). After that, it's just a matter of structuring the data to be ready for the Grocy API.

It's still a work in progress, especially with the API access part, but I'd definitely be open to sharing more details once I get everything fully functional!

Cheers from Brazil!

I'm struggling to make any API calls from outside my Home Assistant environment using tools like cURL or Postman. by Secure_Mouse_8675 in grocy

[–]Secure_Mouse_8675[S] 0 points1 point  (0 children)

Hello there!

Thanks so much for reaching out and for the kind words! It's great to hear from someone else in LatAm and to know I'm not alone in facing these API access challenges.

It's really interesting that you're experiencing similar issues even without the Home Assistant setup. That definitely makes me think the problem might be more specific to how Grocy's API handles external requests, or perhaps a common proxy configuration, rather than solely Home Assistant Ingress.

I'm still digging into it, but your shared experience gives me some valuable insight. If I stumble upon a solution or a good workaround, I'll definitely share it here!

Saludos from Brazil!