The Best Way To Send HTTP Requests

Поделиться
HTML-код
  • Опубликовано: 28 сен 2024
  • Join us on Discord, get the source code (and support the channel 🙂): / amantinband
    Clean Architecture Zero to Hero: dometrain.com/...
    Domain-Driven Design Zero to Hero: dometrain.com/...
    All videos in this playlist: • ASP.NET 8 REST API Tut...
    In this video we'll cover HTTP Files. We'll learn more or less everything there is to know about them:
    1. What are HTTP Files
    2. What is the standard format
    3. How to send HTTP requests via VSCode using the REST Client extension
    4. How to define file variables
    5. How to define environment variables
    6. How to structure the HTTP requests inside a project
    Hope you enjoy!
    Connect with me on 'em socials:
    Twitter: / amantinband
    LinkedIn: / amantinband
    GitHub: github.com/ama...
    Check out all my courses on DomeTrain:
    dometrain.com/...
    Support the channel and get the source code:
    / amantinband
    Thanks for watching, don't forget to like & comment & subscribe! ❤️ 💻
  • НаукаНаука

Комментарии • 121

  • @brandonbraner
    @brandonbraner 3 месяца назад +19

    If you are using postman for single requests you are missing the power of it

    • @ljoffrey
      @ljoffrey 3 месяца назад

      For sure. Bruno is a good alternative too

  • @vibes992000
    @vibes992000 3 месяца назад +2

    Thanks for the video. Can you also have part 2 of this video where you process the json responses and set new values of environment variables and then send 2nd http request to some another endpoint after that (using json data values from success response data).

  • @ayyubayyubzada4090
    @ayyubayyubzada4090 4 месяца назад +8

    Cant we declare token as dynamically?
    For example, declare it as global variable in somewhere which requests to the authentication endpoint and fetches the token. Based on the response of auth request(from another file), it uses always the newest valid token for all endpoints.

    • @cliffwakefield
      @cliffwakefield 4 месяца назад +2

      This is the use case I would need to move many of my collections away from Postman.

    • @bogdanb904
      @bogdanb904 4 месяца назад

      @@cliffwakefield I don't think this will ever work with SSO also. Which Postman supports.

  • @SerafimMakris
    @SerafimMakris 4 месяца назад +3

    incredibly good option to send requests through your IDE to check if your application works correctly. My point of view for this http logic are, needed to be add more features to be actual usable like do something with the response body or Code (set attribute based on response message) . :D a big lesson from Amichai again :D

    • @Jianju69
      @Jianju69 3 месяца назад

      I'm still catching up with the rest of the group, but your comment is helpful. So, once we have the application working the way we like, is the .http-file still used in the application (to make HTTP requests,) or is it only for use in the IDE?

    • @exomo1
      @exomo1 3 месяца назад +1

      @@Jianju69 The http files are just for testing and documentation. The application code does not use those files.

  • @afgone123456
    @afgone123456 4 месяца назад +12

    How to would you do the environment management in VS?

    • @po6577
      @po6577 4 месяца назад +4

      this is probably the most important thing postman can do, without this, i will not event think about switching to any tool

    • @nicholaschun6889
      @nicholaschun6889 3 месяца назад

      That will be a game changer if added to http files

  • @nirajchandrajoshi
    @nirajchandrajoshi 4 месяца назад +6

    Thank you for this great content ❤.
    I have just one question why you don’t use visual studio ? Or if I ask my question differently then how to use http files in visual studio and where to put token in global variables. Please help.

  • @hoki8296
    @hoki8296 6 дней назад

    Wow, It will be really helpful for me.
    RIP postman.

  • @michaldivismusic
    @michaldivismusic 4 месяца назад +8

    The http file is nice, but is there a way to automatically generate it from an Open API spec? Keeping these up to date sounds like a pain.

    • @Petrovich2049
      @Petrovich2049 4 месяца назад

      It’s a pain only if you already have a big undocumented api. Otherwise for every api update just update the doc, realistically your api doesn’t /shouldn’t change so much that it becomes a drag, and in the end you have a doc written by a human with nuances explained, so later on your consumers waste less of your time with questions.

    • @QuintonCraig
      @QuintonCraig 3 месяца назад

      @@Petrovich2049 Postman will generate the collections based on an OpenAPI spec. If you are new to a proj, this can save a crazy amount of time when you need to get a workable collection online.

  • @sergenalishiwa9097
    @sergenalishiwa9097 4 месяца назад +5

    Postman supports GRPC and more.

  • @OlleHellman
    @OlleHellman 3 месяца назад +2

    How do you handle secrets and making sure the token is not checked in?

  • @petter.envall
    @petter.envall 4 месяца назад +1

    It is unfortunate that the variables are stored in the vscode settings instead of something like a file in the root of the httpfiles, or project root for that matter

  • @JJ-hg7um
    @JJ-hg7um 4 месяца назад +6

    Thanks for the useful video. I like it. BTW is there a way to automatically fetch the token before a request?

    • @amantinband
      @amantinband  4 месяца назад +4

      You can have the value auto populated via a previous response: github.com/Huachao/vscode-restclient?tab=readme-ov-file#request-variables

  • @vitek0585
    @vitek0585 4 месяца назад +6

    It is a great way for simple requests, but when it is necessary to login and then fetch a token to reuse in future requests, this tool is not convenient

    • @geoffreyolson9720
      @geoffreyolson9720 3 месяца назад +1

      Does postman handle that better, because I had the same problem using postman? I would have to login with the browser, then copy the token and manually set the token variable.

    • @vitek0585
      @vitek0585 3 месяца назад

      @@geoffreyolson9720 It is not needed to perform those actions, you just need to parse response and assign extracted value to the variable. That is available in the Tests tab. Here is a short example: let responseData = pm.response.json();
      pm.environment.set("categoryId", responseData[0].id);
      Get first element of the array and assign id value to the variable. After that the categoryId is available for the further requests

    • @vitek0585
      @vitek0585 3 месяца назад +2

      No need to perform those manual actions. There is Tests tab where the response result can be handled. To extract and assign the value to the environment variable just need to parse response: let responseData = pm.response.json();
      pm.environment.set("categoryId", responseData[0].id);
      In the example above I get the first item and assign extracted id to the environment variable. After that the variable can be used as value for the further requests

    • @GabrieleCannata
      @GabrieleCannata 3 месяца назад

      @@vitek0585 Exactly. Not a Postman fan, but that tool is on another level. Also standard OAuth2 authentication are handled automatically.

    • @QuintonCraig
      @QuintonCraig 3 месяца назад

      @@geoffreyolson9720 just use the authorization of the collection, and configure the request to inherit the token from the collection

  • @SouravBanik90
    @SouravBanik90 3 месяца назад

    Can we even use this for writing tests? What’s the point of this? Just to send one request? What if we have to generate the tokens every time for sending a request? How to do that? How to store a value from a request to be sent in another?

  • @congjuny
    @congjuny 3 месяца назад +1

    does it do prescript, test, or read variable values from a file etc?

  • @JordanHumbertodeSouza
    @JordanHumbertodeSouza 3 месяца назад

    What about when you need to get the bearer token from request a response header? is there a way to update the env variable on the fly?

  • @fezhaez
    @fezhaez 4 месяца назад +1

    If you delete postman how do you browse the internet?

  • @joseluiseiguren7827
    @joseluiseiguren7827 3 месяца назад

    How do you overwrite the token env variable from a login post request?
    So you don't have to paste the token manually in the env variables file
    Thanks

  • @gjermundification
    @gjermundification 3 месяца назад +1

    Postman? There is cURL.

  • @mauricioaviles6914
    @mauricioaviles6914 3 месяца назад

    Have you used hurl? How does it compare to http files?

  • @Mhblabla
    @Mhblabla 4 месяца назад +1

    This is inferior to OpenApi specs and generating clients from that

  • @KevinLyda
    @KevinLyda 3 месяца назад

    Define an OpenAPI document. Use those tools to test the API, generate the server and client, verify requests and responses, etc.

  • @knkootbaoat6759
    @knkootbaoat6759 3 месяца назад +3

    i smashed that subscriber button and looking forward to the future vids

  • @arsenaghajanyan9741
    @arsenaghajanyan9741 4 месяца назад

    Is there a way to preserve cookies sent from api for the following requests?

  • @tidus93
    @tidus93 4 месяца назад

    Are enviroment variables able to be handled the same way for .http files in Rider/VS aswell?

  • @ylazerson
    @ylazerson 3 месяца назад

    great video - thanks!

  • @Dough296
    @Dough296 3 месяца назад

    Nice share !
    Is there a way to create a auth.http file so it retrieves the token + stores it in a workspace variable ?
    This way we should not need to manage tokens by hand.

  • @shayvt
    @shayvt 4 месяца назад +3

    Another good one! :)
    Thank you Amichai

  • @fedor_U
    @fedor_U 2 месяца назад

    Things get ugly if you try to send encoded form data...

  • @fraserm7163
    @fraserm7163 4 месяца назад

    Hopefully this will support NTLM authentication in the future.

  • @马剑-i2q
    @马剑-i2q 3 месяца назад

    how to stream response as I call OpenAI's API?

  • @xBodro
    @xBodro 4 месяца назад +4

    Cool but not even close to what postman offers out of the box.

  • @devmarkmonster
    @devmarkmonster 4 месяца назад

    The Jetbrains IDE also has a similar plugin, however they are not fully compatible with each other :-(.

    • @kewqie
      @kewqie 4 месяца назад

      Rider supports http files by default, no external plugin needed.

    • @devmarkmonster
      @devmarkmonster 4 месяца назад

      @@kewqie yes but the http files are not 100% compatible

  • @cocacola7535
    @cocacola7535 4 месяца назад

    But how can we upload file with http files?

  • @AslamNazeerShaikh
    @AslamNazeerShaikh 4 месяца назад

    Great thanks ❤🎉

  • @bnssoftware3292
    @bnssoftware3292 4 месяца назад

    Very cool!

  • @d47im5e
    @d47im5e 3 месяца назад

    Nah, this one needs some work. For simple rest clients, I think IDEA's http client is better, In any project i can write http files, and i can write javascript code before and after each request that can do tests, set global variables and use them in other requests. But this extension seems good for this use case... Congrats and keep it up!

  • @egozMaster
    @egozMaster 3 месяца назад

    i dont want create files just for make request

  • @rnavedojr
    @rnavedojr 3 месяца назад

    That's cool, but I personally prefer postman because of all the functionalities it has.

  • @QuintonCraig
    @QuintonCraig 3 месяца назад

    Seems like way more work for no benefit other than to avoid postman.
    MS Edge has basic functionality, imports collections, etx. Probably more useful than this lol

  • @amirdaraee
    @amirdaraee 4 месяца назад +2

    Dislike for the clickbait. postman is much more than just a tool for sending requests. Ability to write scripts to run before and after a request, creating collections, the cli, convenient ui and much more.

    • @Petrovich2049
      @Petrovich2049 4 месяца назад

      It’s such a slow and heavy app, costs another subscription too. Many features you listed can be easily replicated in vs code and I’d argue more convenient to use too.
      But personally I’m using Obsidian instead

  • @tommcmeekin1
    @tommcmeekin1 4 месяца назад

    Hey, does anyone know why adding in an api key header works in vs but not in vsc: X-API-KEY: thisismyverysecurekey

    • @nanonukes
      @nanonukes 4 месяца назад +1

      If the api parses your request in a case sensitive manner, you may encounter this behaviour. Rest client makes it all lowercase iirc.

  • @hoanghaitruong9209
    @hoanghaitruong9209 3 месяца назад +1

    haha so how about to share your api to non-dev teammate example QA to try the api?

  • @djchen1
    @djchen1 4 месяца назад +2

    Does anybody still use curl? I find it handy while working on barebone VMs. Also if you installed tools like proxyman it can trace all http/rest requests made in your system

  • @syedhoque9057
    @syedhoque9057 4 месяца назад +4

    What tool do you use to annotate ?

  • @soverain
    @soverain 4 месяца назад +4

    The fact that environment variables are stored in a vs code workspace config file seems like a big no to me. On my team everyone has its own config file stuffed with plugins configurations.

    • @bogdanb904
      @bogdanb904 4 месяца назад

      Yup. That's a bit of bs. Also would force everyone into using VS Code.

    • @soverain
      @soverain 4 месяца назад

      @@bogdanb904 I think env variables are handled differently on other IDES.

    • @dweblinveltz5035
      @dweblinveltz5035 4 месяца назад

      Also not a fan. There should be some .http specific env file similar to Node's dotenv.

  • @abhishekbagchi6052
    @abhishekbagchi6052 4 месяца назад +3

    Cool video. One Question what if I want to update the token in Environment value from a request

  • @ChrisWard74
    @ChrisWard74 3 месяца назад +1

    So I can do this all in postman. What about populating the variable with a HTTP call? Say I have an API call to get a token and then want to use that token in other API calls? I can do this in Postman, can it be done with this?

  • @MacheteBang
    @MacheteBang 4 месяца назад +3

    More of a vscode question, but is it possible to have multiple workspace settings files? I.e. i want one that has all the "public" settings and a second that has user / password in gitignore (but not in the "user" settings as they are shared across many projects.)

  • @DeejayMAK11
    @DeejayMAK11 3 месяца назад +3

    Is there a way to create variable which will have dynamic values (from a response of another endpoint)?

    • @blank001
      @blank001 3 месяца назад

      In Postman yes, not sure about this one

  • @FarukLuki111
    @FarukLuki111 3 месяца назад +1

    Postman was SO MUCH MORE features than what you show here! So far away from „rip postman“!

  • @DaminGamerMC
    @DaminGamerMC 4 месяца назад +2

    postman only wins because of testing calpabilities and scripts pre and post request

    • @QuintonCraig
      @QuintonCraig 3 месяца назад

      ehh, probably more than that. Runner is pretty huge

  • @DrHeinzDoofenshmirtz
    @DrHeinzDoofenshmirtz 4 месяца назад +1

    Please also get into how to avoid to write API keys and other secrets in the .http files.

  • @exomo1
    @exomo1 3 месяца назад

    Nice video. It looks like VS Code or any other IDE that has support for http files can be used a replacement for postman in a lot of cases. Still it's missing some of the features that make Postman a great tool. What I need the most is authentication (e.g. OAuth2) and token management and a way for scripting requests (e.g. calculating a challenge/reponse value).

  • @dealerpriest
    @dealerpriest 3 месяца назад

    Superflous use of the phrase "go ahead and..." has popped up all over youtube. I wonder what's the reason behind this?

  • @zebraforceone
    @zebraforceone 3 месяца назад

    I use insomnia these days, it's quite good

  • @Fanatic17
    @Fanatic17 3 месяца назад

    honestly insomnia is better for defining tokens and variables

  • @chrisnuk
    @chrisnuk 3 месяца назад

    It needs NTLM authorisation added

  • @ricardoribeiro4560
    @ricardoribeiro4560 4 месяца назад +1

    In the case of authentication, is it possible to automatically fill in the token variable when sending the request?

    • @amantinband
      @amantinband  4 месяца назад +3

      Yes, check this out: github.com/Huachao/vscode-restclient?tab=readme-ov-file#request-variables

  • @wildmusical
    @wildmusical 4 месяца назад +2

    Insomnia Rest is also a good client. It is Open source (Apache 2.0), supports GraphQL, REST, WebSockets, SSE and gRPC. You can create test suites, load and edit OpenAPI. It is also extensible with plugins.
    One problem is that the official release now forces you to login (like Postman).
    However, you can use an older release (up to 2023.5.8) or just use a fork which cuts the login.

    • @orecruncher7930
      @orecruncher7930 4 месяца назад +4

      I find this "login trend" somewhat concerning. If I am working on an API that is internal to my organization, the last thing I need is to provide the definition for said API to a 3rd party.

  • @kukulis100
    @kukulis100 3 месяца назад

    microsoft minion

  • @Amr-Ibrahim-AI
    @Amr-Ibrahim-AI 3 месяца назад

    Thank you for the comprehensive video.
    What's the software you use to add annotations to the video? I mean those neon-like rectangles and arrows.

  • @ehsangoodarzi2123
    @ehsangoodarzi2123 3 месяца назад

    hi Amichai, thanks for great content.
    just an idea to make it better , it took for times to understand why my visual Studio doesn't recognize .HTTP like yours. and then I installed REST Client extension. now it works.
    edit: you explained it ,sorry my fault😂

  • @legui444532
    @legui444532 4 месяца назад

    It's basically using postman with a lot of extra steps, I think i don't need another thing to manage😅, but maybe I will have to learn this at some point of my carreer 😐

  • @Noceo
    @Noceo 3 месяца назад

    Would love to see a video on how/if this can be utilized in a test setting. E.g. calling a number of endpoint in the CD pipeline, after deployment.

  • @MadanaGopalVankaraboina
    @MadanaGopalVankaraboina 4 месяца назад

    @amantinband please make a play list for rest api you are teaching perfectly like beginner to masterrest api's. if not possiblle please suggest a one rest api tutorial to become master. Thank you

  • @Vietnamkid1993
    @Vietnamkid1993 4 месяца назад

    What do you do about storing tokens until they are needed? I use a secure workspace in postman.

  • @DrHeinzDoofenshmirtz
    @DrHeinzDoofenshmirtz 4 месяца назад

    I just watched the intro, and I am thinking: Please convert me!

  • @artiefischel2579
    @artiefischel2579 3 месяца назад

    Thanks. I never could figure out Postman.

  • @BBMG74
    @BBMG74 3 месяца назад

    Wow! Will test it out on Monday. Looks, that it's the first time I really can get rid of Postman

  • @MrYerak5
    @MrYerak5 3 месяца назад

    Dont forget to ignore files in git with sensative data

  • @MaThMaTa1000
    @MaThMaTa1000 4 месяца назад

    Too much of a hassle to work with GraphQL tho

  • @tchial0
    @tchial0 4 месяца назад +13

    Hahaha! The postman team will hate this video.

    • @amantinband
      @amantinband  4 месяца назад +9

      To be fair postman is an excellent product with a ton of features, but I completely replaced it with http files over the past few years

    • @avatar201206
      @avatar201206 4 месяца назад +6

      What about writing to the env. after a request has been send?

    • @jeffersantosss
      @jeffersantosss 4 месяца назад

      @@avatar201206 great question

    • @matthewbramer7654
      @matthewbramer7654 3 месяца назад

      ​@@amantinbandHow can you use rest client without storing an API key in settings.json?

  • @shomari169
    @shomari169 4 месяца назад

    Did you vscode or vs in your coursed please?

  • @gluckchaim
    @gluckchaim 4 месяца назад

    Great content

  • @7th_CAV_Trooper
    @7th_CAV_Trooper 4 месяца назад

    This is slick.

  • @cliffwakefield
    @cliffwakefield 4 месяца назад

    Is there a way to define environments and variables that works across IDE's?

    • @pilotboba
      @pilotboba 4 месяца назад

      Probably not... since this is for the VS code plugin. But, would be nice it possible. That said, many times you don't want those stored with your source. Would be nice though it if supported .env files and or environment variables and then all IDS could adopt that.

  • @aaartist_yt
    @aaartist_yt 4 месяца назад +2

    I use this extensions for a while (~2-3 years) now. This way to do and organize the requests is still highly underrated. 👍
    PS: How do you to this colored marks in your screencast? Is this a post-production or do you draw them live?

    • @amantinband
      @amantinband  4 месяца назад +1

      Live - it’s called presentify

  • @monterreymxisfun3627
    @monterreymxisfun3627 3 месяца назад +1

    I still prefer the plain old Python requests library.

  • @Eirenarch
    @Eirenarch 4 месяца назад +3

    I always enjoy when people who advocate for feature folders forget about them when faced with non .cs file extension :)
    Services folder - bad, entities folder - bad, requests folder - totally different, this one is good :)

  • @James-l5s7k
    @James-l5s7k 4 месяца назад +2

    Never liked postman.

    • @T___Brown
      @T___Brown 3 месяца назад

      The tabs system drives me crazy