-
|
Hello, I am successfully using the Cloud API of Android SMS Gateway from Google Apps Script. The provided example script (from https://github.com/android-sms-gateway/example-google-apps-script) works fine with the cloud endpoint (https://api.sms-gate.app/3rdparty/v1/messages). However, I would also like to send SMS messages via the Local Server API (when my phone and computer are on the same LAN). Here is the issue I’m facing: When I send a request with curl to my phone’s local server (http://192.168.0.21:8080/message), it works correctly. Example: This sends the SMS without any problem. But when I try to send the exact same request from Google Apps Script using UrlFetchApp.fetch, the local server always responds with 400 Bad Request. The Cloud API works fine from the same script, so authentication and JSON formatting are correct. Here is what I have tried in Apps Script (simplified): The request fails with: So my questions are:
Thank you very much! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hello! Thank you for using the app. Here are answers to your specific questions:
Google Apps Script runs on Google's servers in their cloud infrastructure, not on your local machine. When your script tries to connect to There are two main options to access the local server outside of your local network:
However, in your case, it is recommended to use a public/private server. See also https://docs.sms-gate.app/faq/local-server/#why-cant-i-access-the-local-server-from-the-internet |
Beta Was this translation helpful? Give feedback.
Hello!
Thank you for using the app.
Here are answers to your specific questions:
Yes, the Local Server API uses the same JSON format and Basic Authentication as the Cloud API. The request structure you're using should be identical for both endpoints.
There are no known incompatibilities between UrlFetchApp and local server endpoints that would cause 400 Bad Request errors specifically.
Your Google Apps Script code appears correct. The problem isn't with the script itself, but with network accessibility.
Google Apps Script runs on Google's servers in their cloud infrastructure, not on your local machine. When your script tries to connect to
http://192.168.0.21:8080, it's attempting…