Using HttpClient in .NET Core to Connect to APIs in C#

IAmTimCorey May 27, 2020
Video Thumbnail
IAmTimCorey Logo

IAmTimCorey

View Channel

About

My goal is to make your life easier, specifically when it comes to learning software development. I remember what it was like to not know even what questions to ask. In every video I do, I try to answer those questions. You will notice that I don't usually do quick videos. That's because I would rather help you understand rather than just padding my watch percentages. If you want more in-depth training, feel free to head over to my website (https://www.iamtimcorey.com) where I have courses dedicated to C#, SQL, and more.

Video Description

How do you safely connect to APIs in .NET Core using C#? HttpClient is the way to go, but doing right is important. Otherwise, you could exhaust your connection pool and cause issues in your application. Source Code: https://www.iamtimcorey.com/downloads/?code=HttpClient Mailing List: https://signup.iamtimcorey.com/ Purchase Courses: https://iamtimcorey.com 0:00 - Intro 0:56 - Blazor server demo app 2:27 - Add Htpp Client service in startup.cs 3:36 - Http.Json NuGet reference 4:48 - New Blazor page: Razor component 5:55 - Data models from json data 14:15 - Editing Blazor page: Page name and navigation link 16:16 - Inject and use Http client: long way 26:40 - Editing Blazor page: Blazor page render logic 31:19 - Running Demo App 33:22 - Inject and use Http client with try - catch 36:29 - Http client with base url from appsettings.json 43:02 - Summary and concluding remarks Thanks to Ralfs HBK for the chapter breakdown

You May Also Like

Must-Have Slime Making Essentials

AI-recommended products based on this video

Loading...
Elmer's Disappearing Purple School Glue Stick, 20G, 0.7-Ounce Each, 3-Pack (61666Q)

Elmer's Disappearing Purple School Glue Stick, 20G, 0.7-Ounce Each, 3-Pack (61666Q)

(2,547)
$5.59
FREE delivery Mon, Sep 15 on your first order
10K+ bought in past month
Loading...
ESR for iPhone 16 Case, Military-Grade Protection, Shockproof Air Guard Corners, Yellowing-Resistant Acrylic Back, Phone Case for iPhone 16, Air Armor Series, New Clear Blue

ESR for iPhone 16 Case, Military-Grade Protection, Shockproof Air Guard Corners, Yellowing-Resistant Acrylic Back, Phone Case for iPhone 16, Air Armor Series, New Clear Blue

(657)
$12.99
FREE delivery Sat, Jun 14 on your first order
Loading...
Yarxiawin Phone Case for Samsung S25 Case with Ring Stand Magnetic Compatible with Magsafe Wireless Charger, Pink Bumper Cover Samsung Galaxy S25 Case Clear Shockproof (Blue)

Yarxiawin Phone Case for Samsung S25 Case with Ring Stand Magnetic Compatible with Magsafe Wireless Charger, Pink Bumper Cover Samsung Galaxy S25 Case Clear Shockproof (Blue)

(0)
$20.23
FREE delivery Sat, Jun 14 on your first order
Loading...
GuaGua for Galaxy S25 Case Samsung S25 Case Glow in The Dark Noctilucent Luminous Cover Space Nebula Slim Thin Shockproof Protective Phone Cases for Samsung S25, Purple/Blue

GuaGua for Galaxy S25 Case Samsung S25 Case Glow in The Dark Noctilucent Luminous Cover Space Nebula Slim Thin Shockproof Protective Phone Cases for Samsung S25, Purple/Blue

(18)
$13.86
FREE delivery Sat, Jun 14 on your first order
50+ bought in past month
Loading...
LEGO Marvel Spider-Man's Car and Doc Ock Building Set, Spidey and His Amazing Friends Buildable Toy for Kids 4 Plus Years Old with Glow in The Dark Pieces, 10789

LEGO Marvel Spider-Man's Car and Doc Ock Building Set, Spidey and His Amazing Friends Buildable Toy for Kids 4 Plus Years Old with Glow in The Dark Pieces, 10789

(3,122)
$13.42
FREE delivery Sat, Jun 14 on your first order
700+ bought in past month
Loading...
Kids Rock Painting Kit - Glow in The Dark - Arts & Crafts Easter Gifts for Boys and Girls Ages 4-12 - Craft Activities Kits - Creative Art Toys for 4, 5, 6, 7, 8, 9, 10, 11 & 12 Year Old Kids

Kids Rock Painting Kit - Glow in The Dark - Arts & Crafts Easter Gifts for Boys and Girls Ages 4-12 - Craft Activities Kits - Creative Art Toys for 4, 5, 6, 7, 8, 9, 10, 11 & 12 Year Old Kids

(4,653)
$24.99
FREE delivery Sat, Jun 14 on your first order
1K+ bought in past month
Loading...
Sukakimi Fort Building Kit, Glow In The Dark 155 Pcs Kids Fort Building Kit Construction Toys Diy Crazy Forts Indoor Outdoor For 4,5,6,7,8,9,10 Years Old Boys Girls

Sukakimi Fort Building Kit, Glow In The Dark 155 Pcs Kids Fort Building Kit Construction Toys Diy Crazy Forts Indoor Outdoor For 4,5,6,7,8,9,10 Years Old Boys Girls

(9)
$9.99
FREE delivery Sun, Jul 6 on your first order
Loading...
Spigen Case for iPhone 16 Plus Case, Liquid Crystal Glitter Designed for Apple iPhone 16 Plus - Crystal Quartz

Spigen Case for iPhone 16 Plus Case, Liquid Crystal Glitter Designed for Apple iPhone 16 Plus - Crystal Quartz

(760)
$18.99
FREE delivery Sat, Jun 14 on your first order
Loading...
LITTLEFUN Decorate Your Own Baseball Cap with Glitter Gem Stickers for Kids Crafts Toys Gifts - Girls Birthday Presents

LITTLEFUN Decorate Your Own Baseball Cap with Glitter Gem Stickers for Kids Crafts Toys Gifts - Girls Birthday Presents

(56)
$28.99
FREE delivery Sat, Jun 14 on your first order
300+ bought in past month
Loading...
Furiet for Samsung Galaxy S24/S25 5G Floral Wallet Case with Flip Zipper Purse Wrist Strap Shoulder Strap Luxury Glitter PU Leather Card Holder Stand Phone Cover for S 24 24S 25 25S G5 Women Purple

Furiet for Samsung Galaxy S24/S25 5G Floral Wallet Case with Flip Zipper Purse Wrist Strap Shoulder Strap Luxury Glitter PU Leather Card Holder Stand Phone Cover for S 24 24S 25 25S G5 Women Purple

(0)
$58.59$58.31
FREE delivery Jun 13 - 17 Only 6 left in stock.
Loading...
Generic Jelly Shoes for Girls, Kid Fishermen Sandals, Princess Birthday Toddler Glitter Sandal Summer Beach Shoe Footwear

Generic Jelly Shoes for Girls, Kid Fishermen Sandals, Princess Birthday Toddler Glitter Sandal Summer Beach Shoe Footwear

(0)
$17.97
FREE delivery Jun 17 - 26
Loading...
KINGRACK 3 Step Ladder, Aluminium Folding Step Stool with Wide Anti-Slip Pedal, Portable Slim Lightweight Ladder for Home Kitchen and Office, Stepladder with Multi-Function, 330lbs Capacity, Silver Global Recycled Standard

KINGRACK 3 Step Ladder, Aluminium Folding Step Stool with Wide Anti-Slip Pedal, Portable Slim Lightweight Ladder for Home Kitchen and Office, Stepladder with Multi-Function, 330lbs Capacity, Silver Global Recycled Standard

(2,853)
$69.99
FREE delivery Sat, Jun 28