From 59f3fad2e6a7802846086e57860438b515f0f413 Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 1 Nov 2024 10:41:34 +0100 Subject: [PATCH] Fixed wrong `Http.Methods` This commit fixes wrong `Http.Methods` (it was set `POST`, but needed `GET` and vice reverse). Fixed #138 --- .../MoonrakerClient.Database.cs | 2 -- .../MoonrakerClient.Printers.cs | 13 ------------- src/MoonrakerSharpWebApi/MoonrakerClient.WebCam.cs | 1 - src/MoonrakerSharpWebApi/MoonrakerClient.cs | 11 +++++------ 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/MoonrakerSharpWebApi/MoonrakerClient.Database.cs b/src/MoonrakerSharpWebApi/MoonrakerClient.Database.cs index 15a1628..f0ae3e7 100644 --- a/src/MoonrakerSharpWebApi/MoonrakerClient.Database.cs +++ b/src/MoonrakerSharpWebApi/MoonrakerClient.Database.cs @@ -35,7 +35,6 @@ public async Task> ListDatabaseNamespacesAsync() command: "database/list", jsonObject: null, authHeaders: AuthHeaders, - //urlSegments: urlSegments, cts: default ) .ConfigureAwait(false); @@ -105,7 +104,6 @@ public async Task> GetDatabaseItemAsync(string namesp // If namespace is missing, just return an empty resultObject now else return resultObject; } - Dictionary urlSegments = new() { { "namespace", namespaceName } diff --git a/src/MoonrakerSharpWebApi/MoonrakerClient.Printers.cs b/src/MoonrakerSharpWebApi/MoonrakerClient.Printers.cs index 8c6b454..894c132 100644 --- a/src/MoonrakerSharpWebApi/MoonrakerClient.Printers.cs +++ b/src/MoonrakerSharpWebApi/MoonrakerClient.Printers.cs @@ -86,8 +86,6 @@ public async Task RefreshPrinterInfoAsync() KlipperPrinterStateMessageResult? resultObject = null; try { - //object cmd = new { name = ScriptName }; - string targetUri = $"{MoonrakerCommands.Printer}"; result = await SendRestApiRequestAsync( requestTargetUri: targetUri, @@ -95,7 +93,6 @@ public async Task RefreshPrinterInfoAsync() command: "info", jsonObject: null, authHeaders: AuthHeaders, - //urlSegments: urlSegements, cts: default ) .ConfigureAwait(false); @@ -128,8 +125,6 @@ public async Task EmergencyStopPrinterAsync() { try { - //object cmd = new { name = ScriptName }; - string targetUri = $"{MoonrakerCommands.Printer}"; IRestApiRequestRespone? result = await SendRestApiRequestAsync( requestTargetUri: targetUri, @@ -137,7 +132,6 @@ public async Task EmergencyStopPrinterAsync() command: "emergency_stop", jsonObject: null, authHeaders: AuthHeaders, - //urlSegments: urlSegements, cts: default ) .ConfigureAwait(false); @@ -159,7 +153,6 @@ public async Task RestartPrinterAsync() { try { - //object cmd = new { name = ScriptName }; string targetUri = $"{MoonrakerCommands.Printer}"; IRestApiRequestRespone? result = await SendRestApiRequestAsync( requestTargetUri: targetUri, @@ -167,7 +160,6 @@ public async Task RestartPrinterAsync() command: "restart", jsonObject: null, authHeaders: AuthHeaders, - //urlSegments: urlSegements, cts: default ) .ConfigureAwait(false); @@ -189,7 +181,6 @@ public async Task RestartFirmwareAsync() { try { - //object cmd = new { name = ScriptName }; string targetUri = $"{MoonrakerCommands.Printer}"; IRestApiRequestRespone? result = await SendRestApiRequestAsync( requestTargetUri: targetUri, @@ -197,7 +188,6 @@ public async Task RestartFirmwareAsync() command: "firmware_restart", jsonObject: null, authHeaders: AuthHeaders, - //urlSegments: urlSegements, cts: default ) .ConfigureAwait(false); @@ -319,7 +309,6 @@ public async Task> GetPrinterObjectListAsync(string startsWith = "" List resultObject = []; try { - //object cmd = new { name = ScriptName }; string targetUri = $"{MoonrakerCommands.Printer}"; result = await SendRestApiRequestAsync( requestTargetUri: targetUri, @@ -327,7 +316,6 @@ public async Task> GetPrinterObjectListAsync(string startsWith = "" command: "objects/list", jsonObject: null, authHeaders: AuthHeaders, - //urlSegments: urlSegements, cts: default ) .ConfigureAwait(false); @@ -1268,7 +1256,6 @@ public async Task SubscribeAllPrinterObjectStatusAsync(long? connectionI command: "query_endstops/status", jsonObject: null, authHeaders: AuthHeaders, - //urlSegments: urlSegements, cts: default ) .ConfigureAwait(false); diff --git a/src/MoonrakerSharpWebApi/MoonrakerClient.WebCam.cs b/src/MoonrakerSharpWebApi/MoonrakerClient.WebCam.cs index d7c2fff..808b49b 100644 --- a/src/MoonrakerSharpWebApi/MoonrakerClient.WebCam.cs +++ b/src/MoonrakerSharpWebApi/MoonrakerClient.WebCam.cs @@ -32,7 +32,6 @@ public partial class MoonrakerClient command: "webcams/list", jsonObject: null, authHeaders: AuthHeaders, - //urlSegments: urlSegments, cts: default ) .ConfigureAwait(false); diff --git a/src/MoonrakerSharpWebApi/MoonrakerClient.cs b/src/MoonrakerSharpWebApi/MoonrakerClient.cs index d1d6279..6abc825 100644 --- a/src/MoonrakerSharpWebApi/MoonrakerClient.cs +++ b/src/MoonrakerSharpWebApi/MoonrakerClient.cs @@ -1350,7 +1350,7 @@ public async Task> GetGcodeHelpAsync() string targetUri = $"{MoonrakerCommands.Printer}"; result = await SendRestApiRequestAsync( requestTargetUri: targetUri, - method: Method.Post, + method: Method.Get, command: "gcode/help", jsonObject: null, authHeaders: AuthHeaders, @@ -1568,7 +1568,7 @@ public async Task MoveAxesAsync( string targetUri = $"{MoonrakerCommands.Machine}"; result = await SendRestApiRequestAsync( requestTargetUri: targetUri, - method: Method.Post, + method: Method.Get, command: "system_info", jsonObject: null, authHeaders: AuthHeaders, @@ -2873,7 +2873,7 @@ await SendRestApiRequestAsync(MoonrakerCommandBase.machine, Method.Get, $"device public async Task> SetDeviceStateAsync(string device, KlipperDeviceActions action) { IRestApiRequestRespone? result = null; - Dictionary resultObject = new(); + Dictionary resultObject = []; try { Dictionary urlSegments = new() @@ -2975,7 +2975,7 @@ await SendRestApiRequestAsync(MoonrakerCommandBase.machine, Method.Get, $"device public async Task> SetBatchDeviceOnAsync(string[] devices) { IRestApiRequestRespone? result = null; - Dictionary resultObject = new(); + Dictionary resultObject = []; try { StringBuilder deviceList = new(); @@ -3367,7 +3367,7 @@ await SendRestApiRequestAsync(MoonrakerCommandBase.api, Method.Post, "printer/co } } - public Task SendOctoPrintApiGcodeCommandAsync(string command) => SendOctoPrintApiGcodeCommandAsync(new string[] { command }); + public Task SendOctoPrintApiGcodeCommandAsync(string command) => SendOctoPrintApiGcodeCommandAsync([command]); public async Task> GetOctoPrintApiPrinterProfilesAsync() { @@ -3492,7 +3492,6 @@ await SendRestApiRequestAsync(MoonrakerCommandBase.server, Method.Get, $"history command: $"history/totals", jsonObject: null, authHeaders: AuthHeaders, - //urlSegments: urlSegments, cts: default ) .ConfigureAwait(false);