diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/PostTask.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/PostTask.java index ea3aef65..2bc44e88 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/PostTask.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/PostTask.java @@ -28,7 +28,7 @@ public class PostTask extends AsyncTask { * params[0] Syncthing hostname * params[1] URI to call * params[2] Syncthing API key - * params[3] The request content + * params[3] The request content (optional) */ @Override protected Void doInBackground(String... params) { @@ -39,7 +39,9 @@ public class PostTask extends AsyncTask { post.addHeader(new BasicHeader("X-API-Key", params[2])); try { - post.setEntity(new StringEntity(params[3])); + if (params.length > 2) { + post.setEntity(new StringEntity(params[3])); + } httpclient.execute(post); } catch (IOException e) { diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java index d635ecd5..cef2b4e2 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java @@ -157,7 +157,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener { * Restarts the syncthing binary. */ public void restart() { - new PostTask().execute(mUrl, PostTask.URI_RESTART, ""); + new PostTask().execute(mUrl, PostTask.URI_RESTART); } /**