commit
Change to POST
diff --git a/api-helper/README.md b/api-helper/README.md
index fcd13df..0ff50fd 100644
--- a/api-helper/README.md
+++ b/api-helper/README.md
@@ -4,10 +4,11 @@ A little Android app that quietly tells your own API how your Pixel is doing —
charging, low-power mode, Wi-Fi, Bluetooth earbuds, and roughly where it is. It's the
free, self-hosted answer to those paid "battery status" apps, built for one phone: mine.
-Under the hood it just hits your endpoint with a GET request and your secret key in a header:
+Under the hood it just POSTs to your endpoint with the fields in the query string and your
+secret key in a header (no request body):
```
-GET https://doughmination.uk/v2/devices?device=pixel&level=25&charging=1&lpm=0&wifi=Home
+POST https://doughmination.uk/v2/devices?device=pixel&level=25&charging=1&lpm=0&wifi=Home
X-Battery-Key: <your key>
```
diff --git a/api-helper/app/src/main/java/uk/doughmination/devicereporter/Reporter.kt b/api-helper/app/src/main/java/uk/doughmination/devicereporter/Reporter.kt
index 0a5117d..71b537f 100644
--- a/api-helper/app/src/main/java/uk/doughmination/devicereporter/Reporter.kt
+++ b/api-helper/app/src/main/java/uk/doughmination/devicereporter/Reporter.kt
@@ -54,11 +54,13 @@ object Reporter {
val urlStr = buildUrl(prefs, snap)
return try {
val conn = (URL(urlStr).openConnection() as HttpURLConnection).apply {
- requestMethod = "GET"
+ requestMethod = "POST"
connectTimeout = 15_000
readTimeout = 15_000
setRequestProperty("X-Battery-Key", prefs.apiKey)
setRequestProperty("Accept", "application/json")
+ // POST with no body — fields stay in the query string.
+ setRequestProperty("Content-Length", "0")
instanceFollowRedirects = true
}
val code = conn.responseCode
@@ -70,7 +72,7 @@ object Reporter {
""
}
conn.disconnect()
- Log.i(TAG, "GET $urlStr -> $code")
+ Log.i(TAG, "POST $urlStr -> $code")
Result(ok, code, if (ok) "OK" else "HTTP $code $body")
} catch (e: Exception) {
Log.w(TAG, "report failed: ${e.message}")