Problems calling WebActions from Rest-API
Hi,
I'm trying to call a web action with a Rest-API call. However I always get the {ok:false} back.
This is my request uri: http://192.168.10.112:3344/printer/api/Prusa_i3_MK3S?a=webCallExecute&data={%22Name%22:%22LightsOff%22%2c%22Params%22:[%22test%22]}&apikey=....
I took the format from the Websocket action:
This is the C# call of it.
Thanks for your help!
I'm trying to call a web action with a Rest-API call. However I always get the {ok:false} back.
This is my request uri: http://192.168.10.112:3344/printer/api/Prusa_i3_MK3S?a=webCallExecute&data={%22Name%22:%22LightsOff%22%2c%22Params%22:[%22test%22]}&apikey=....
I took the format from the Websocket action:
- {action: "webCallExecute", data: {name: "LightsOff", params: ["Test"]}, printer: "Prusa_i3_MK3S",…}
- action: "webCallExecute"
- callback_id: 1402
- data: {name: "LightsOff", params: ["Test"]}
- printer: "Prusa_i3_MK3S"
This is the C# call of it.
var client = new RestClient(string.Format("{0}{1}:{2}", httpProtocol, ServerAddress, Port));
var request = new RestRequest(!string.IsNullOrEmpty(PrinterName) ? "printer/api/{slug}" : "printer/api");
request.RequestFormat = DataFormat.Json;
request.Method = Method.POST;
request.Timeout = 2500;
if (!string.IsNullOrEmpty(PrinterName))
{
request.AddUrlSegment("slug", PrinterName);
}
request.AddParameter("a", Command, ParameterType.QueryString);
request.AddParameter("data", JsonConvert.SerializeObject(JsonData), ParameterType.QueryString);
request.AddParameter("apikey", API, ParameterType.QueryString);
var fullUri = client.BuildUri(request);
var respone = await client.ExecuteAsync(request);
var result = respone.Content;
Thanks for your help!
Comments
Correct link is:
http://192.168.10.112:3344/printer/api/Prusa_i3_MK3S?a=webCallExecute&data={%22name%22:%22LightsOff%22%2c%22params%22:[%22test%22]}&apikey=...
Watch you with parameter names! They are case sensitive so "name" not "Name" and "params" not "Params"
thanks for your help. It's working now with this url.
Yes it is, would yo mind if you edited the posts and remove the key?
Thank you!