joggs 24 Posted July 13, 2018 Share Posted July 13, 2018 (edited) Hi, I am building a wpf application, where you can manage all your tv shows and episodes. I'd appreciate guidance how to proceed regarding how to delete tv episodes where I have a handle to the selected episode id's, using the c# ApiClient. I cannot see that there are any public delete methods available in the c# ApiClient, so I'm thinking about using the Swagger libraryservice "delete items" function by using the c# method GetApiUrl("/items/"+ episodeId). Would that be a good approach? Or maybe there are easier ways. Thanks Edited July 13, 2018 by joggs Link to comment Share on other sites More sharing options...
Luke 37096 Posted July 13, 2018 Share Posted July 13, 2018 It will need to be added if it's not already there. Or could just send a request to the url using getapiurl. Pull requests are welcome. Thanks. Link to comment Share on other sites More sharing options...
joggs 24 Posted July 13, 2018 Author Share Posted July 13, 2018 It will need to be added if it's not already there. Or could just send a request to the url using getapiurl. Pull requests are welcome. Thanks. I was successful deleting the episode. There is a private DeleteAsync method in the ApiClient class that works well for my usecase. I created my own apiClient class and derived from the original one, adding the following method(copied from the baseclass): public async Task<T> DeleteAsync<T>(string url, CancellationToken cancellationToken = default(CancellationToken)) where T : class { url = AddDataFormat(url); using (var stream = await HttpClient.SendAsync(new HttpRequest { Url = url, CancellationToken = cancellationToken, RequestHeaders = HttpHeaders, Method = "DELETE" }).ConfigureAwait(false)) { return DeserializeFromStream<T>(stream); } } And I called it by using var url = ApiClientHandler.GetApiClient().GetApiUrl($"Items/{episodeId}"); var response= await ApiClientHandler.GetApiClient().DeleteAsync<EmptyRequestResult>(url); (ApiClientHandler.GetApiClient() is my own singleton code..) Link to comment Share on other sites More sharing options...
Luke 37096 Posted July 13, 2018 Share Posted July 13, 2018 Great, thanks for the info! 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