How To Call An API in C# - Examples, Best Practices, Memory Management, and Pitfalls

  Рет қаралды 436,550

IAmTimCorey

IAmTimCorey

Күн бұрын

It seems like everything has an API these days but have you ever wondered how to make use of an API in your application? It turns out that it isn't really that hard at all. In this video, I am going to show you how to easily load the data from two different APIs into an application. Along the way, I will show you how to avoid some memory issues and other best practices around talking to APIs
Full courses: www.iamtimcorey.com/
Source Code: leadmagnets.app/?Resource=Cal...
Patreon: / iamtimcorey
Newsletter signup: signup.iamtimcorey.com/
0:00 - Intro
1:00 - Demo application walk-through
4:09 - Setting up API calling: WebApi.Client and Newtonsoft.json NuGet references
6:02 - Setting up API calling: HttpClient
13:48 - Setting up API calling: API calls
19:14 - Setting up API calling: Reading and working with json data
28:18 - Loading image in WPF (form a website)
35:29 - Adding events in WPF application: wiring up action buttons
39:40 - Note on information Cashing
42:55 - Sunrise-sunset API: Nested json objects, API calls, WPF events, displaying information
51:56 - Loading other WPF forms from MainWindow
53:38 - Summary and concluding remarks
Chapter breakdown by Ralfs HBK

Пікірлер: 589
@craigmcloughlin9361
@craigmcloughlin9361 3 жыл бұрын
Still churning out new videos and immediately responding to comments from 3-year old videos :-) You're a credit to the community! Thanks for the videos and keep up the good work.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@nogo1880
@nogo1880 3 жыл бұрын
I have watched a few videos about calling API's. And I originally skipped this one because of the length, and I was so anxious to get started. After taking the time to watch it, I regret skipping over it. This video was so informative, and Tim really has a way of explaining everything very thoroughly. I am now a fan, and will be watching as many of your videos as possible. Thank you for taking the time to create these videos.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for watching and trusting Tim to help expand your skills
@shubhamsahrawat903
@shubhamsahrawat903 4 жыл бұрын
Thank you, Tim for pouring down all the information ( as much as you could ) from your heart and not holding anything back!!!! I'm feeling lucky to got stumbled upon this video amongst plethora of content out there!!!! Looking forward to learn new things about programming/coding/web development!! THANK YOU SIR!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are most welcome. Thanks for watching.
@beerguy1320
@beerguy1320 2 жыл бұрын
As a newbie to coding in general i appreciate the advice on the comic model. Just specifying the properties you need is golden nuggets. I’m always like ‘give me all the things magical internet box’ and I’ll figure out what I need, whilst my program grinds to a halt. Thank you Tim Corey for knowing what I need before I do.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
I am glad it was so helpful.
@RalfsBalodis
@RalfsBalodis 3 жыл бұрын
0:00 - Intro 1:00 - Demo application walk-through 4:09 - Setting up API calling: WebApi.Client and Newtonsoft.json NuGet references 6:02 - Setting up API calling: HttpClient 13:48 - Setting up API calling: API calls 19:14 - Setting up API calling: Reading and working with json data 28:18 - Loading image in WPF (form a website) 35:29 - Adding events in WPF application: wiring up action buttons 39:40 - Note on information Cashing 42:55 - Sunrise-sunset API: Nested json objects, API calls, WPF events, displaying information 51:56 - Loading other WPF forms from MainWindow 53:38 - Summary and concluding remarks
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thanks again. You are helping the entire community with these. Much appreciated
@steveemanuel1167
@steveemanuel1167 2 жыл бұрын
J
@RickGtr271
@RickGtr271 5 жыл бұрын
Luckily I found this video. You're the only one who can describe these techniques in an organized way. I just subscribed to your channel too.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thanks and welcome aboard.
@patrickbacon8492
@patrickbacon8492 Жыл бұрын
Thank you! I really appreciate how you have given back to the c# community.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@hachadwick
@hachadwick 2 жыл бұрын
I wish I could "like" this video more than once. You are a great teacher.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thank you!
@hachadwick
@hachadwick 2 жыл бұрын
@@IAmTimCorey Do you have and videos on WINUI?
@Dame4Lyf3
@Dame4Lyf3 5 жыл бұрын
I've been confused about API and integrating with C#, watched various videos about this subject and was still lost, your explanation has made it more clear. Thanks for your tutorials - looking forward to the continued courses.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I am so glad I was able to clear up the confusion for you.
@alilubab207
@alilubab207 2 жыл бұрын
That's an amazing and hard to find sort of tutorial on youtube, thank you!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@alexanderrupp1209
@alexanderrupp1209 2 жыл бұрын
I don’t really comment often but I just want to say thank you so much. You have been a really big help on a side project I’m working on and you explained everything so well!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
I'm so glad!
@milanstraka4194
@milanstraka4194 5 жыл бұрын
Great video, one of the best on KZbin when it comes to C#
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thanks!
@romedov882
@romedov882 4 жыл бұрын
I wondered how to connect to a web API for a long time. I sought out for the resolution for a long time and I couldn't understand anything until I've watched this video. Thank you a lot, sir.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad I could help!
@filipzeman9523
@filipzeman9523 4 жыл бұрын
Did this in generics because of knowledge from your other video about generics. Thank you, always happy to take a challenge when you suggest something extra.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Excellent!
@IamCagedAnimal
@IamCagedAnimal 4 жыл бұрын
Great tutorial as usual from you Tim, gj! Keep it coming..
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thank you!
@chellyengert234
@chellyengert234 5 жыл бұрын
I just started my first ever api project at work. This video really saved me. Very clear. Tremendously helpful.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Great!
@CRBarchager
@CRBarchager 5 жыл бұрын
I just got an assignment for a job where I had to do exactly this and it helped me alot. Thank you!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Awesome!
@muslimshexany6066
@muslimshexany6066 3 жыл бұрын
thank you very much Tim you are helping people a lot with your amazingly explained tutorials!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad you think so!
@markovvoz8849
@markovvoz8849 5 жыл бұрын
Omg just what i needed. Love you
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Excellent!
@paulofernandoee
@paulofernandoee 2 жыл бұрын
As always, excellent video!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thanks!
@florianrager9631
@florianrager9631 5 жыл бұрын
Thank you for this video, it cleared a lot of confusing stuff about using API's up for me. Keep up the good work!! Greetings from Austria
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Great!
@onyebuchiboss
@onyebuchiboss 5 жыл бұрын
Been waiting for this, Like forever.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Well, I'm glad it finally came for you.
@RonSpwan11
@RonSpwan11 4 жыл бұрын
Thank you so MUCH! This was awesome!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@madhusaivemulamada3556
@madhusaivemulamada3556 2 жыл бұрын
Thanks Tim, these concepts helped me in an interview
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Awesome!
@HanselGraciadelBusto
@HanselGraciadelBusto 3 жыл бұрын
Great video Tim!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thanks!
@annmershawn1102
@annmershawn1102 4 жыл бұрын
Thank you Tim. This was very informative and helped a lot.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@RaterisimoCBA
@RaterisimoCBA 2 жыл бұрын
Thank you Tim once again for great content ! Super helpful, now I just need to practice making calls to other APIs so that it sticks. :)
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@EliminateMundane
@EliminateMundane 4 жыл бұрын
I am probably a crappy starting up programmer who rarely subscribes to channels and rarely ever likes videos. For you I make an exception, this video was super helpful and this kind of content is rarely ever free. Thank you and God Bless the beard.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are most welcome.
@franciscoj.escobar9451
@franciscoj.escobar9451 4 жыл бұрын
Love your classes, best wishes from Argentina AR
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Awesome! Thank you!
@shadowthehedgehog2727
@shadowthehedgehog2727 4 жыл бұрын
Thank you so much! This video was fun to watch :)
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@Francisco-Gutierrez
@Francisco-Gutierrez 5 жыл бұрын
Great video Tim.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@db0455
@db0455 5 жыл бұрын
Thanks Tim,have a nice day!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@torbennielsen7642
@torbennielsen7642 2 жыл бұрын
Super Tim, thank you for a great video
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@sumanthsumanth3862
@sumanthsumanth3862 2 жыл бұрын
Thanks Corey Great work!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@alvaromateus282
@alvaromateus282 5 жыл бұрын
Tim, I need to tankyou, your classes are great, you have one of the bests teaching aproach I've ever seen. Keep this way, you are helping a lot of people. Tanks again, god bless!!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I am glad you are enjoying the videos.
@BungieFrog
@BungieFrog 4 жыл бұрын
Tim, Great tutorial. I would recommend anyone watching this to watch it all the way through. This really simplified everything I seen online. Too many people were making this really complicated but you solved that. I was originally looking for a tutorial on just getting and using data from a REST Api, after that was going to review getting images from that Api and displaying them in the app and then cycling from page to page. Tim I would recommend a different title on this video though which is why I went down the rabbit trail looking at other videos first. "C# WPF XAML REST API Tutorial - Examples, Best Practices, Memory Management, and Pitfalls" Though I have been programming for 20 years I am new to C# and I know ASP.NET uses C# and there is a difference between WPF XAML and Forms - hence my I suggest adding in those other 2 to the title. I subscribed and look forward to lots more videos.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad you enjoyed the video.
@sintektic1311
@sintektic1311 4 жыл бұрын
LOVE THIS GUY
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thanks!
@dchan5251
@dchan5251 5 жыл бұрын
thank you fro the demo. Good Job !
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@RAM-ff8dy
@RAM-ff8dy 5 жыл бұрын
Great Video Tim, I always wait for your new videos, can you make a video on Serialization and Deserialization, Thanks
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I'll upgrade the priority of that on my suggestion list.
@JackiePrime
@JackiePrime 5 жыл бұрын
We love you tim Corey
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thank you.
@gilramirez4949
@gilramirez4949 4 жыл бұрын
Thanks again Tim! Will try that now.
@SHiroo0
@SHiroo0 4 жыл бұрын
Could you please share your "try", I think I have same problem as you :) "type": "champion", "format": "standAloneComplex", "version": "10.3.1", "data": { "ChampName1": { "version": "10.3.1", "id": "Aatrox", "key": "266", "name": "Aatrox", "title": "the Darkin Blade", "blurb": "Once honored defenders of Shurima against the Void, ...", "info": { "attack": 8, .. }, "image": { "full": "Aatrox.png", .. }, "tags": [ "Fighter", "Tank" ], "partype": "Blood Well", "stats": { "hp": 580, .. } }, "ChampName2": { "version": "10.3.1", "id": "Ahri", "key": "103", ... }, "image": { "full": "Ahri.png", ... }, "tags": [ "Mage", "Assassin" ], "partype": "Mana", "stats": { "hp": 526, .... } },
@SHiroo0
@SHiroo0 4 жыл бұрын
This is how i fixed my issue I hope it helps you. Added it to a List of my model like Tim said =) GLHF List championData = await response.Content.ReadAsAsync();
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Sounds good.
@alexanderkarczewski982
@alexanderkarczewski982 5 жыл бұрын
Once agin Tim good job. Thanks
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@mayurithakor4158
@mayurithakor4158 Жыл бұрын
Hello Sir, Thank you for sharing video. Its very helpful.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@joshuawieczorek1759
@joshuawieczorek1759 5 жыл бұрын
Thanks for this really great video.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@gareth6326
@gareth6326 Жыл бұрын
Thanks for the video. The sunrise-sunset security certificate expired 7 days ago. I have dropped the s from htpps and everything works.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks for sharing.
@Bidombamb
@Bidombamb 21 күн бұрын
ohhh thank you soo much! i made a weather program with a console app. it did run succsessfully, but i didn't understand how the properties worked. this video helped me understand it! :)
@IAmTimCorey
@IAmTimCorey 21 күн бұрын
I am glad it was helpful.
@grzegorzzawadzki3048
@grzegorzzawadzki3048 4 жыл бұрын
Thanks for help bro!!!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Happy to help
@felsonexe9061
@felsonexe9061 3 жыл бұрын
Your killing it ❤️
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thanks!
@artursz1993
@artursz1993 4 жыл бұрын
Thank you! I was just making similar things in my project, trying to figure out the best practices. GET is cool, but I also need to POST things and I guess I have found them with title: Posting Sales Data to an API - A TimCo Retail Manager Video. Also looking forward watching all the Role management videos, cause I also implemented the default web api authorization using /Token. So far I was just doing manual service calls with Postman, to make users, roles, and adding roles to users :D
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I'm glad you are finding the resources you need to accomplish your mission.
@AbubakrMahdiSan
@AbubakrMahdiSan 4 жыл бұрын
Thanks, Very much ,Tim
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@Antho333332
@Antho333332 5 жыл бұрын
Huge thanks man, was a bit disappointed you didn't explained how to caching and authenticate using OAuth2
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Trying to cover authentication is tough because everyone does it differently. Usually the API documents how to do that. As for caching, I'll be covering that in a future video.
@IQISHIKI
@IQISHIKI 23 күн бұрын
Amazing Guide, thank you man
@IAmTimCorey
@IAmTimCorey 22 күн бұрын
You are welcome.
@jamesbarker117
@jamesbarker117 3 жыл бұрын
Great tutorial! :)
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thank you! Cheers!
@eightchickens
@eightchickens 2 жыл бұрын
Thank you!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@personalchaoyu8732
@personalchaoyu8732 3 жыл бұрын
Thanks for this wonderful video, i had to use 1.25 speed :D . I added a buffer to store existing calls results ,a spinner to show Ajax call in progress and a button to read out ALT text :D BTW, this Comics are kinda fun to read
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@aileenmasonwestphal8713
@aileenmasonwestphal8713 2 жыл бұрын
Hi Tim! In your video you mention building a generic Api data processor. Have you made or are you planning on making a course on that subject? ...and thank you for your videos!!
@gokaysirin
@gokaysirin Жыл бұрын
thank u YouAreTimCorey
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@russellhires7693
@russellhires7693 Жыл бұрын
Hi Tim - what made you want to use a static method for the instantiation of the ApiHelper.ApiClient instead of via constructor? What I typically do is create a customized httpClient in a class that inherits from HttpClient. This way I can use DI to bring it in. Any thoughts on this?
@vinuhosanagar1
@vinuhosanagar1 5 жыл бұрын
Thank you Sir. Can you please do a video on serialization and deserialization in C# may be considering a wpf datagrid serialized into XML. I found many examples, but when you explain it will be complete for sure
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
It is on the suggestion list.
@HEXiN1
@HEXiN1 2 жыл бұрын
Bro Thanks you 🥺.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@gordonruthven7656
@gordonruthven7656 Жыл бұрын
Firstly, i would like to say thank you for everything you are doing on here. you are a legend. Secondly, can you explain why you have chosen xaml over windows form, could the same outcome be achieved in both?
@IAmTimCorey
@IAmTimCorey Жыл бұрын
The same can be achieved with WinForms, yes. WPF is a more modern UI platform, which is why I default to it.
@ianmckain5499
@ianmckain5499 3 жыл бұрын
Hi Tim. Great video, really helpful for someone coming from JS and React. Do you have a video on how to access nested objects in a JSON response?
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Not specifically, although when you parse the JSON into an object, it can handle nested objects.
@krellon
@krellon 5 жыл бұрын
Great video! I did think though that you were going to look at API calls through a wrapper. Ie, calling a library written in C from C#. Maybe a future subject 😉👍
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Ah, I see. I'll add that to the suggestion list.
@priyankakulkarni84
@priyankakulkarni84 3 жыл бұрын
Thanks Tim. Wanted to check if you have any series for automating apis
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Automating them? No, sorry.
@TomerDanel02
@TomerDanel02 Жыл бұрын
Is advanced video for this one came out? like youve said in the end
@miguellouisrivadenera6300
@miguellouisrivadenera6300 3 жыл бұрын
Hi Tim, does the values of LoadSunInformation update for each day? In addition does this tutorial include constantly updating information when the JSON or website file is update?
@rezamohamadzadeh620
@rezamohamadzadeh620 5 жыл бұрын
tnx man !!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@tostgulen
@tostgulen 3 жыл бұрын
As always, a fantastic tutorial. Learned a lot. Thank you. Could you do a similar tutorial on how to query GraphQL with C#?
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@justindupuis4089
@justindupuis4089 3 жыл бұрын
I second this hard, I've been jumping back and forth between which gql client library to use or whether to use a client library at all instead of the bare httpclient class.
@Starlife2206
@Starlife2206 2 жыл бұрын
Thank you
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@deeproy7292
@deeproy7292 4 жыл бұрын
thanks tim
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@tomlee7073
@tomlee7073 3 жыл бұрын
Yet another one of your videos that addresses something I am working on, your channel is great man thank you so much! I've seen a lot of conflicting information about HttpClient and using 1 instance of it for the life time of the app just because it implements IDisposable. I completely understand that using one instance of HttpClient in a console, windows forms, wpf, etc is fine, but what about in web mvc projects. Isnt it slightly different because if you have a static var holding the instance of HttpClient isnt that shared across everyone using your web app/site, also what is the best way to hold that once instance var for mvc? I should point out that the reason why I found your video is because I have a web app that Im building that uses a few different apis, and Im wondering how to use HttpClient instances that are kept for the lifetime of the app when Im using mvc5 and if that really is the best practice for each of the external api's Im using as each one would need a separate HttpClient as the base url address would be different
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
So they've made the HttpClient a lot better in .NET Core. Check out this video on it: kzbin.info/www/bejne/majKlJ5noJWMgbc Basically, you use the HttpClientFactory to create clients for you (or recycle them - it doesn't matter to you which it chooses to use). That way they are safely created and disposed without overloading the system or exhausting the ports.
@chrisspellman5952
@chrisspellman5952 5 жыл бұрын
This video covered exactly what I've been trying to figure out. Every thing I got from SO was basically the same code snippet a million times and wasn't helpful.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I'm glad the video was so helpful.
@armandopenaleonett1258
@armandopenaleonett1258 4 жыл бұрын
Hello Thank you for your videos, hey in this one do you talk about Validation ?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I don't remember. Sorry.
@santiagopiaggio2099
@santiagopiaggio2099 4 жыл бұрын
Hey tim, are you planning on doing a video about hosting a mock of an api with predetermined responses? If not, do you have any video / guide you might recommend?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
It isn't on the schedule but I can add it to the suggestion list. I don't have any current recommendations on that topic.
@misterwoody_
@misterwoody_ 3 жыл бұрын
Hi Tim. Thanks for all the great content. This may be one for the back burner or a separate resources video related to consuming rest APIs. There seem to be a wide variety of tutorial videos that relate to consuming a single endpoint, but not really anything that I've been able to find in terms of completing an "object graph". For example, if there's a theroetical API with a single product endpoint that can be retrieved via simple id key and that product has a number of related lookup id's for other related objects with separate endpoints - what would the options be in retrieving those or keeping them either cached or in memory to improve the efficiency of requests? Many thanks
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thanks, I had added it to my list
@jeisonsalazar71
@jeisonsalazar71 2 жыл бұрын
gracias... thank you
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@jonnyjazzz
@jonnyjazzz 2 жыл бұрын
Hi Tim. Is there a pattern available to handle APIs that work based off a Request/Response with Events? To be more clear: The API accepts a Request Type and a Request ID, and raises an event when the request is fulfilled, referencing the Request ID. My first take on this involved a lot of globals to manage state and flow and all sorts of code in the event handlers, and having not looked at it months, I'm lost as to where I was going with it.
@jakers918
@jakers918 4 жыл бұрын
Would you happen to have a tutorial like this, but from the beginning, such as creating the boxes with "previous" "sun information" "next" etc?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
This playlist should help: kzbin.info/aero/PLLWMQd6PeGY3QEHCmCWaUKNhmFFdIDxE8
@rbwheels
@rbwheels 3 жыл бұрын
This is another great tutorial. May I ask if you can do a tutorial about POST method on API in C# Best Practices, Memory Management and Pitfalls
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Great suggestion! ... added to the list.
@LGviews
@LGviews 5 жыл бұрын
Since i got stuck with this problem, it might be helpful to other beginners : if you are using an API that requests a simple token identification, pass the token as a header, not in the uri, as such: APIClient.DefaultRequestHeaders.Add("Authorization", "YourTokenHere");
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Correct. We actually just covered this today in the TimCo Retail Manager course video.
@LGviews
@LGviews 5 жыл бұрын
@@IAmTimCorey yop, just watched it! a few hours too late for me :D
@bobi9749
@bobi9749 5 жыл бұрын
whats with refresh token?
@TomerDanel02
@TomerDanel02 Жыл бұрын
Hi Tim, thank you very much for the video, when i tried to use propery that in the json is list it didnt worked for me.. you might know what I should do difference? Thanks
@IAmTimCorey
@IAmTimCorey Жыл бұрын
I would recommend doing a bit of debugging. Check the object again carefully, check your property names, etc.
@simonlarsen6343
@simonlarsen6343 Жыл бұрын
Hi Tim, I could really use some help implementing a double nested array, any help is very appreciated
@thethomasproject
@thethomasproject 4 жыл бұрын
Question for you Tim, at the point of 19 mins ish, you talk about using the 'using' statement to clean things up. I totally understand that. If I didn't want to use this method, could I create the response variable and when I"m done, just perform at response.Dispose(); at the end to accomplish the same thing? Thanks!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Not quite. If you have an unhandled exception, the Dispose method would not be called.
@gregboyer5724
@gregboyer5724 2 жыл бұрын
Hi, I am writing an application that will continuously run on a server to make a call to an API every hour. At what point should I enter the API key. Should this be done inside the InitializeClient void or will cause security issues having this open continuously?
@Konoko_kun
@Konoko_kun 3 жыл бұрын
This is gonna be so useful! Thank you so much! But what if the data I want to retrieve is in XML format? How would I do that? Is there a tutorial you would recommand? Thank you in advance!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
It almost never is (and can usually be changed to json even if they offer XML). However, if you needed to handle XML, you would need to use the XML parser to convert it into usable data.
@emaus8344
@emaus8344 3 жыл бұрын
Hi Tim, have you got a tut where is shown how to get data from API when having Authorization with tokens?
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Check out the TimCo Retail Manager series. Right now we are wiring a Blazor WebAssembly application to an API that has authentication with bearer tokens which include role authorizations. We also wired up a WPF project to the same API.
@abenetbeyene3398
@abenetbeyene3398 5 жыл бұрын
awesome
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thanks.
@jamesnaylor8492
@jamesnaylor8492 4 жыл бұрын
one question, been watching your SOLID videos and am wondering if the "newing up" of HttpClient and some other stuff in the ApiHelper class is considered as acceptable for some reason, or if you just did it to keep things simple for the video. Would you recommend using something like DIP here? or would it be overkill for this type of application, trying to get a bit of a sense of when and where to use the principles as I'm aware over use of them is a common thing, especially for those who have just recently understood how to use them and why. Thanks again for your videos btw 10/10 :)
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Good questions. The HttpClient has always been a sticky issue since it was something that, if done wrong, could cause socket exhaustion. There have been some major improvements in .NET Core and now we can ask for a HttpClientFactory (from DI) and then use the clients as needed without worrying about socket exhaustion (the factory takes care of when to create new ones, etc.)
@joshuaknight9816
@joshuaknight9816 4 жыл бұрын
Good, but missed abit about REST apis different calls, like POST. I think the first hurdle people will have using it on real project is you will need to login to the REST service, so first call they need is POST and know how to format C# strings into JSON style data, and decode success response back. Some debugging tips about REST APIs, like using apps like Postman are invaluable too.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I did mention that briefly. I debated adding some type of authenticated call but the problem is that each API does things differently. Showing how to do one will not help you do another and might actually confuse the viewer. I do make post calls in the TimCo Retail Manager series (that are authenticated).
@majesticartist8761
@majesticartist8761 3 жыл бұрын
Hey man i like your tutorials mind making a video on how to make a full website with C sharp im staggered learning C sharp so i'm trying to expand my learning in C sharp i only have like 4.5 months of learning C sharp.I've already learned the beginneer and intermediate and advanced tutorials after i learned what the variables and data types do and everything else it seems i've hit a wall, mind helping me advance?
@abpeti
@abpeti 3 жыл бұрын
Great video. One question: What if a json response from an api contains an array? How do you map that to properties? For example: "weather": [ { "id": 804, "main": "Clouds", "description": "overcast clouds", "icon": "04n" } ]
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
In this specific example, you could have this property: public List Weather { get; set; } You can also paste the json into C# using the Paste Special option to see how the class structure would work.
@amitbendet9165
@amitbendet9165 2 жыл бұрын
Hi, When running the program at 33:46. Am getting the error “Program does not contain a static “Main” method suitable for an entry point” - what a wrong with my code? Thank you for the help’
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
It sounds like you are trying to start your class library instead of your API project. Right-click on your API project and select "Set as startup project".
@joyfultrader
@joyfultrader 4 жыл бұрын
Thank you so much. This was a very helpful video for me as I'm building out a new app that heavily utilizes JSON data. I recreated your lesson here using Xamarin and it all works quite well. However, my next big challenge is to consume JSON data which is stock price data and so my JSON has many rows that contain "high" "low" "open" "close" data. In your "Processor" class, could you demonstrate the code you would use to cycle through and deserialize that JSON into a Collection/List that can then still be accessed on the front end? There are a lot of example floating around out there, but I can't find "the one" that actually works. Any advice is appreciated.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Not sure what you are looking to have demonstrated. If you have an array of objects coming back, just as for it as a List during deserialization and it will work.
@Nashmar
@Nashmar 5 жыл бұрын
Hey Tim, nice channel :) . I have a question. I am a bit confused about lifecycle of HttpClient. I have checked many resources according to this topic, but they all seems to have different opinion on the topic. Should I create a new instance of HttpClient inside an using block every time while making specific request or should I make HttpClient instance to be reused in whole application aka make it singleton ?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
It is the recommendation from Microsoft to open the connection once and use it throughout the lifespan of your application: docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client#create-and-initialize-httpclient
@tommyc7963
@tommyc7963 Жыл бұрын
不错
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks!
@cal4353
@cal4353 3 жыл бұрын
Hello, love your videos how do i extract data from a website and manipulate it if the API is not available.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
If the website does not provide an API, they most likely do not want you to get the data directly. Trying to get it directly using scraping or another technique is then usually illegal.
@animeboy93
@animeboy93 5 жыл бұрын
Do you also have a video on how to make proper post calls using this same style? I would like to know what the proper way of posting data to a service that would send it to a database. You don't exactly want sensitive data being visible on the web. It would also be nice to look at this in the way of registering a user and logging in since it's a real life and practical example.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I do not yet but it is coming. The key is that I have to pick one API for uploading. In this case, I will make my own but what I do in that won't be the same as what you do with other APIs. As for sensitive data, if you POST data and you are using HTTPS, you are protected (or at least 99.9% protected).
@bridgey2012
@bridgey2012 5 жыл бұрын
This is great thank you, but how do I do this when the api returns xml? Also how do I handle json when it is returned in an array?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
C# should be able to parse XML like JSON (although I haven't done it in a while). As for an array, just capture it in a List.
@iamthatiam5779
@iamthatiam5779 3 жыл бұрын
Hi, thank you, your videos are very helpful. I have a question, how should I name my properties in the case when filed in JSON called "solar_noon" or "civil_twilight_end"? Should I name them like Solar_noon or Civil_twilight_end. Is there some solution that let you name properties in CamelCase?
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I typically just match the names. That is simplest. However, you can use attributes to identify what the JSON name is and then use a more C#-like property name.
@fatimaajij428
@fatimaajij428 4 жыл бұрын
Excellent tutorial, now understood how it works, but was wondering if you requesting any files or PDF through API? what sort of properties would we use to display files instead of text?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I don't have any videos on that yet but in general, you need to use a file stream and a file picker on the UI.
@fatimaajij428
@fatimaajij428 4 жыл бұрын
@@IAmTimCorey yeah I used stream and memory stream with byte array and retrieved the document. 👍👍👍
Creating NuGet Packages the easy way with .NET Standard in C#
1:14:57
C# Dependency Injection with Autofac
54:45
IAmTimCorey
Рет қаралды 292 М.
ОДИН ДЕНЬ ИЗ ДЕТСТВА❤️ #shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН
Wait for the last one! 👀
00:28
Josh Horton
Рет қаралды 100 МЛН
Is it Cake or Fake ? 🍰
00:53
A4
Рет қаралды 20 МЛН
Don't Use Polly in .NET Directly. Use this instead!
14:58
Nick Chapsas
Рет қаралды 46 М.
Using HttpClient in .NET Core to Connect to APIs in C#
45:03
IAmTimCorey
Рет қаралды 187 М.
Deep Dive into REST API Design and Implementation Best Practices
12:02
Software Developer Diaries
Рет қаралды 38 М.
10 Coding Principles Explained in 5 Minutes
5:44
ByteByteGo
Рет қаралды 124 М.
God-Tier Developer Roadmap
16:42
Fireship
Рет қаралды 6 МЛН
10 C# Libraries To Save You Time And Energy
33:59
IAmTimCorey
Рет қаралды 204 М.
Delegates in C# - A practical demonstration, including Action and Func
1:09:11
Swagger is Going Away in .NET 9!
10:48
Nick Chapsas
Рет қаралды 87 М.
ОДИН ДЕНЬ ИЗ ДЕТСТВА❤️ #shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН