API access works in curl but UrlFetchApp returns 400 Bad Request

I’m trying to access my Home Assistant API and it works fine using curl - postman:

curl --location --request GET 'https://myha.duckdns.org:8123/api/states' ^
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9............'

but not in Google Apps Script using UrlFetchApp:

function myFunction2() {  
  var ha_url = "https://myha.duckdns.org:8123/api/states"
  Logger.log(ha_url);
  var headers = {
    "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.................",
    "Content-Type": 'application/json',    
  };
  var params = {
    method: 'get',
    headers: headers,
    muteHttpExceptions: true
  };
  var response = UrlFetchApp.fetch(ha_url, params); 
  Logger.log(response.getContentText());
  return response.getContentText();  
}

Google Apps Script returns a 400 Bad Request error.
What am I doing wrong?

Did you check the HA log?
That 400 might typically be returned in case of “unauthorized” proxy

hi, you’re right:
2023-11-14 10:33:04.429 ERROR (MainThread) [homeassistant.components.http.forwarded] A request from a reverse proxy was received from 34.116.33.9, but your HTTP integration is not set-up for reverse proxies

I found this solution,

http:
  use_x_forwarded_for: true
  trusted_proxies:
  - 127.0.0.1
  ip_ban_enabled: true
  login_attempts_threshold: 5

but the address changes with every query:

received from 34.116.22.69, but your HTTP integration is not set-up for reverse proxies
received from 107.178.203.32, but your HTTP integration is not set-up for reverse proxies
received from 35.187.133.46, but your HTTP integration is not set-up for reverse proxies

If you cannot find a list of google’s reverse proxy, you can disable that security by doing

trusted_proxies:
  - 0.0.0.0/0 

thanks for the speed Chris, unfortunately same mistake