mickle026 400 Posted May 22, 2023 Share Posted May 22, 2023 Send http URL via IService Route to C# code - Is it possible? in my JS function SendRequest() { console.log("Sending Request"); var e = document.getElementById("txtRequestData"); var RequestUrlString = e.value; if (RequestUrlString.length > 0 && (RequestUrlString.toLowerCase().substring(0, 7) == "http://" || RequestUrlString.toLowerCase().substring(0, 8) == "https://" || RequestUrlString.toLowerCase().substring(0, 4) == "www.")) { SaveRequestURL(); var nurl = "/ADM/SendRequest?Request=" + RequestUrlString ; ApiClient.getJSON(ApiClient.getUrl(nurl)).then(response => { var dat = response; document.getElementById("replystatus").innerHTML = dat.Text; }).catch(e => { console.log(e); }); } else { reply = "Nothing to request! - Please type a valid URL."; document.getElementById("replystatus").innerHTML = reply; } }; In my C# [Route("/ADM/SendRequest?Request=\"{RequestUrl}\"", "GET", Summary = "Send an URL Link as a Requset ")] public class ADMMetadataRequest : IReturn<object> { [ApiMember(Name = "RequestUrl", Description = "RequestUrl", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] public string RequestUrl { get; set; } public string Text { get; set; } } This c# code causes emby not to even load with an error System.ArgumentException: System.ArgumentException: Route '/ADM/SendRequest?Request={RequestUrl}' on 'ADMMetadataProvider.ADMMetadataRequest' contains invalid chars. changing it because the ? makes it fail , to : [Route("/ADM/SendRequest={RequestUrl}", "GET", Summary = "Send an URL Link as a Requset ")] Changes the error to a browser not found 404 error. It would appear that I cannot send in a http: address like this, of course i can save it to the config file, and then read it frm c#, but is it possible to receive one through the IService Route? I can send it, just not receive it as Emby reports the Route as Not found, ie 404, is there a specific datatype for this? Link to comment Share on other sites More sharing options...
Luke 37060 Posted May 22, 2023 Share Posted May 22, 2023 Try removing the query string from the route definition. 1 Link to comment Share on other sites More sharing options...
mickle026 400 Posted May 22, 2023 Author Share Posted May 22, 2023 Thanks I will try that 1 Link to comment Share on other sites More sharing options...
Cheesegeezer 3086 Posted May 23, 2023 Share Posted May 23, 2023 14 hours ago, Luke said: Try removing the query string from the route definition. Luke a question on this, is there a parameter type to hide the info from the server log. Currently any request via IService is logged, but if i wanted to pass an authToken, for example, and I didn’t want that info logged. Could i used something like ParameterType=“hidden” cheers Link to comment Share on other sites More sharing options...
softworkz 3335 Posted May 23, 2023 Share Posted May 23, 2023 20 hours ago, mickle026 said: It would appear that I cannot send in a http: address like this You need to use the javascript function encodeURI() for being able to send it as a URL parameter. Link to comment Share on other sites More sharing options...
Luke 37060 Posted May 23, 2023 Share Posted May 23, 2023 6 hours ago, Cheesegeezer said: Luke a question on this, is there a parameter type to hide the info from the server log. Currently any request via IService is logged, but if i wanted to pass an authToken, for example, and I didn’t want that info logged. Could i used something like ParameterType=“hidden” cheers Not currently, no, although I have thought in the past that route control over logging might be nice. But haven't had a chance to explore it yet. Link to comment Share on other sites More sharing options...
softworkz 3335 Posted May 23, 2023 Share Posted May 23, 2023 6 hours ago, Cheesegeezer said: Luke a question on this, is there a parameter type to hide the info from the server log. Currently any request via IService is logged, but if i wanted to pass an authToken, for example, and I didn’t want that info logged. Could i used something like ParameterType=“hidden” No, but you can use a POST request instead and send this as part of the post payload. For requests you are making from within Emby server, there are APIs which allow you to mark parts of URLs you are making requests to as private. Please see: Emby SDK Reference: HttpRequestOptions.Sanitation Emby SDK Reference: UrlSanitationOptions Using these options allow you to mark only parts of a URL as sensitive. Whether these parts are visible or sanitized depends on the toggle switch when viewing log files. Link to comment Share on other sites More sharing options...
Cheesegeezer 3086 Posted May 23, 2023 Share Posted May 23, 2023 1 hour ago, Luke said: Not currently, no, although I have thought in the past that route control over logging might be nice. But haven't had a chance to explore it yet. 1 hour ago, softworkz said: No, but you can use a POST request instead and send this as part of the post payload. For requests you are making from within Emby server, there are APIs which allow you to mark parts of URLs you are making requests to as private. Please see: Emby SDK Reference: HttpRequestOptions.Sanitation Emby SDK Reference: UrlSanitationOptions Using these options allow you to mark only parts of a URL as sensitive. Whether these parts are visible or sanitized depends on the toggle switch when viewing log files. Love it guys, i will check up on this Softy. But the i think the links you set are backend and not part of the UI JS post. The server still logs the IService query, post, get, put, etc. i am Probably so wrong on this, my js is absolutely shocking and it is a necessary evil for me. Just a frank lazy and wrong language. anyhoo let me check your links and i can decide tomorrow cheers and good night Link to comment Share on other sites More sharing options...
softworkz 3335 Posted May 23, 2023 Share Posted May 23, 2023 6 minutes ago, Cheesegeezer said: Love it guys, i will check up on this Softy. But the i think the links you set are backend and not part of the UI JS post. The server still logs the IService query, post, get, put, etc. i am Probably so wrong on this, my js is absolutely shocking and it is a necessary evil for me. Just a frank lazy and wrong language. For a request from a js script to an IService endpoint: Use POST. The links are for the case when your plugin C# code makes a request to some external endpoint. It's a different scenario, I just wanted to point out that such capabilities exist for outgoing requests. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now