Problem
- I want to communicate with api while changing IP address, because the server restricts IP address. So, I add X-Forwarded-For header with UrlFetchApp. However, I get an error "Attribute provided with invalid value: Header:X-Forwarded-For "
Question
- How can I solve this problem? Or is there another way?
function myFetch() {
var url = "https://XXXXXXXXX"
var options = { method: "GET" };
options.headers = {
Authorization: "Bearer " + MY_TOKEN,
"X-Forwarded-For": "XXX.XXX.XXX.XXX"
};
var resp = UrlFetchApp.fetch(url, options);
var json = resp.getContentText();
var data = JSON.parse(json);
return data;
}
Tried → Error
- Tried : cURL request. →Success : I can change IP address, and get data.
curl -X GET \
https://XXXXXXXXX \
-H 'Authorization: Bearer MY_TOKEN' \
-H 'X-Forwarded-For: XXX.XXX.XXX.XXX' \
Tried : Delete X-Forwarded-For header. →Error : "API key does not allow access from IP XXX.XXX.XXX.XXX"
Tried : I also add Host header. →Error : "Attribute provided with invalid value: Header:Host".
Does anybody have a solution for my problem? Best regards,