Cheesegeezer 3086 Posted April 22, 2023 Share Posted April 22, 2023 (edited) I just stumbled across this excellent "hidden" feature in Visual Studio. Which lets you test api endpoints without having to run code for testing or even use Swagger to return jsons. It's simply a http file extension. Its epic!! Let me show you.... Create a new folder in your project and call it API Playground or something like that Right click folder and add new item and in C# items you should see http file Select HTTP File and give it a name like Emby API Endpoints once created you can use GET POST PUT & DELETE requests to test any endpoint. you can create and use variables. you just need to add the @ symbol before the name of your variable and to use it in your request you need enclose the variable name in DOUBLE curly braces.... {{myVariable}} To add multiple end point tests you need to do a triple hash key under each request ### and to comment you just need a single # prefix Click the little play icon next to the Endpoint you want to test and boom you will get all the info you need in a json right next to it!!! It's so cool, i didn't know about this amazing feature and wow does it speed up work flow. You can also copy the full json and then create new ModelDto's without even leaving VS!!! @chef @VicMoore @TeamB @ginjaninja @mickle026 @BillOatman This is true Wizardry!!! I'm sure you all knew about it, but i just wanted to share this!! Hope it helps someone else out. Edited April 22, 2023 by Cheesegeezer 5 Link to comment Share on other sites More sharing options...
softworkz 3335 Posted April 22, 2023 Share Posted April 22, 2023 Or you download the Emby.SDK which contains two different C# libraries, both of them cover the complete REST API and include ready-to-use fully-typed classes for every single request and response you can make: https://dev.emby.media/home/sdk/apiclients/Net.RestSharp/README.html https://dev.emby.media/home/sdk/apiclients/Net.AutoRest/README.html Download: https://dev.emby.media/download/index.html Link to comment Share on other sites More sharing options...
Cheesegeezer 3086 Posted April 22, 2023 Author Share Posted April 22, 2023 5 minutes ago, softworkz said: Or you download the Emby.SDK which contains two different C# libraries, both of them cover the complete REST API and include ready-to-use fully-typed classes for every single request and response you can make: https://dev.emby.media/home/sdk/apiclients/Net.RestSharp/README.html https://dev.emby.media/home/sdk/apiclients/Net.AutoRest/README.html Download: https://dev.emby.media/download/index.html Yes i agree, the point of my post was testing the end points not acquiring the endpoints. Although i used Emby as an example… lets say you wanted to use the TMDB API that doesn’t provide a fully rounded SDK. 1 Link to comment Share on other sites More sharing options...
softworkz 3335 Posted April 22, 2023 Share Posted April 22, 2023 Yup, that's surely nice. Hadn't seen this before either! 1 Link to comment Share on other sites More sharing options...
Cheesegeezer 3086 Posted April 22, 2023 Author Share Posted April 22, 2023 5 minutes ago, softworkz said: Yup, that's surely nice. Hadn't seen this before either! It will certainly speed up IMetadataProvider development for you guys and plugin devs!! Link to comment Share on other sites More sharing options...
softworkz 3335 Posted April 22, 2023 Share Posted April 22, 2023 1 minute ago, Cheesegeezer said: It will certainly speed up IMetadataProvider development for you guys and plugin devs!! Well - you don't use REST APIs when developing metadata providers and server plugins... Link to comment Share on other sites More sharing options...
softworkz 3335 Posted April 22, 2023 Share Posted April 22, 2023 Ah, you mean for accessing external APIs? Yes, maybe. I can show you another trick for that: Just run an URL from their documentation in the browser For example, in case of TV-Maze: https://api.tvmaze.com/seasons/1/episodes?embed[]=guestcrew Copy the full json output from the browser In Visual Studio, create a new class file and delete the class Then Edit => Paste Special => Paste JSON as Classes 3 1 Link to comment Share on other sites More sharing options...
Cheesegeezer 3086 Posted April 22, 2023 Author Share Posted April 22, 2023 (edited) 1 hour ago, softworkz said: Ah, you mean for accessing external APIs? Yes, maybe. I can show you another trick for that: Just run an URL from their documentation in the browser For example, in case of TV-Maze: https://api.tvmaze.com/seasons/1/episodes?embed[]=guestcrew Copy the full json output from the browser In Visual Studio, create a new class file and delete the class Then Edit => Paste Special => Paste JSON as Classes I know that one haha use it a lot!! Works for xml files too as there is an option to paste those too! but.. using the http file and running the endpoint inside VS, your json is populated right next to it in a pane. You can copy the json from that pane inside VS and create a new class and paste as you described. Change RootObject class name to something more sensible. I didn’t even leave VS to achieve the same as what you just did hehe Edited April 22, 2023 by Cheesegeezer 1 Link to comment Share on other sites More sharing options...
BillOatman 500 Posted April 22, 2023 Share Posted April 22, 2023 Visual Studio Code also has restclient as a plugin. That's what I tend to use because it's lightweight and it can run on 1 monitor while I have the others for the VS debugger. 1 Link to comment Share on other sites More sharing options...
mickle026 400 Posted April 25, 2023 Share Posted April 25, 2023 (edited) I dont have http file in visual studio, I cannot find what it bundled with to install it either. I have vs 2019 enterprise, which version do you have? Edited April 25, 2023 by mickle026 Link to comment Share on other sites More sharing options...
Cheesegeezer 3086 Posted April 25, 2023 Author Share Posted April 25, 2023 1 hour ago, mickle026 said: I dont have http file in visual studio, I cannot find what it bundled with to install it either. I have vs 2019 enterprise, which version do you have? 1 hour ago, mickle026 said: I dont have http file in visual studio, I cannot find what it bundled with to install it either. I have vs 2019 enterprise, which version do you have? You probably need 2022 17.4 in order to reap the benefits of this. It may even be 17.5 i keep upto date because I’m developing in dotNet Maui and those updates come thick n fadt lol 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