Using http Files in Visual Studio to Test and Document APIs

Sdílet
Vložit
  • čas přidán 4. 06. 2023
  • Testing and documenting APIs in Visual Studio is even easier thanks to the latest update. We can now use http files to execute an API call and see the results right in our editor. Let's see how they work in this 10-minute training video.
    Full Training Courses: IAmTimCorey.com
    Mailing List: signup.iamtimcorey.com/

Komentáře • 65

  • @satyabratamohapatra3397
    @satyabratamohapatra3397 Před rokem +8

    Thank you TIM. Already using it. Personally someone who does not like to go out from IDE during development , this is a great feature.

  • @runtimmytimer
    @runtimmytimer Před rokem +2

    I actually used this today. Was easier than dealing with postman. Thanks.

  • @geoffxander7970
    @geoffxander7970 Před rokem +1

    Thank you. This will save untold amounts of drudgery of dealing with Swagger pages.

  • @pavfrang
    @pavfrang Před rokem

    Thanks Tim, this is huge! I have already started to port my "Postman" stuff to http files. Http files will become the norm most probably!

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      You are welcome.

    • @pavfrang
      @pavfrang Před 11 měsíci

      @@Luke5100 authentication works like a charm - you put the token at the beginning. It depends on the authentication scheme obviously.

  • @johncerpa3782
    @johncerpa3782 Před rokem +1

    HTTP files are really cool. Awesome video

  • @benjaminshinar9509
    @benjaminshinar9509 Před 11 měsíci

    I can see this as documenting to other developers how to use a feature or as a testing suite for them to follow.
    each call is a step that they execute (create an account, get resources, manipulate them, and delete at the end). but it then becomes another duplicate of what should be part integration/e2e tests. and then it goes out of sync and we end up with more files in the source code that nobody updates until something breaks.
    I think this will end up like having scripts in the source control. they are used by two or three people, and then those people leave and nobody knows what to do with the files anymore.

  • @terjes64
    @terjes64 Před rokem +2

    A very nice. So much easier than writing integration-tests. And a lot smoother than having seperate individual postman projects. 👍

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      Thank you!

    • @terjes64
      @terjes64 Před rokem

      @@IAmTimCorey Hi. Visual Studio now comes a built in view called Endpoints Explorer which allows you to generate the requests 👍👍

  • @peymannaji
    @peymannaji Před 3 měsíci

    Thanks for the video. The question is how about getting the first person without knowing its ID (in this case that backend generates GUID) and use that ID in the next request ?

  • @theAutomaTom
    @theAutomaTom Před 3 měsíci

    That looks like a great way to keep your calls with the app so when QA comes knocking, you can hand them a list.

  • @HenryETaylor
    @HenryETaylor Před rokem

    Do you know if they will be adding a way to add comments to the .http files? Maybe supporting markdown in those comments? I'm imagining keeping all of an API's documentation in .http files, with separate use cases for individual (and series of) endpoints, each described in depth within the comments, then demonstrated using custom urls and bodies, each with their own little green button.

  • @korhankonaray
    @korhankonaray Před rokem

    Nice feature. Is content type form-data supported? I've tried but could't be successful.

  • @nikolagenov8881
    @nikolagenov8881 Před 5 měsíci

    How can I test posting a form file? I'm getting an error "Failed to read the request form. Invalid header line: asd".

  • @ahmedifhaam7266
    @ahmedifhaam7266 Před rokem +1

    if we can write more code in those {{}} we could even capture data or tokens in variables, run in loops, add delays, and write entire tests lol, but i think at that point it would be another project in CS more appropriately but, it would be nice to write a littttle bit of code here for documentation purposes, its cool.

  • @volk2ua
    @volk2ua Před rokem +3

    Can you upload source code of this project?

  • @rodrigo_sparlock
    @rodrigo_sparlock Před rokem

    Nice! I used to use a VS Code extension, Rest Client, that offers the same experience.

  • @JoeLizFamily4
    @JoeLizFamily4 Před 11 měsíci

    Looks like a nice feature.

  • @anomalii7720
    @anomalii7720 Před 11 měsíci

    Love it, thanks 👍

  • @Antonio-lt1sp
    @Antonio-lt1sp Před rokem

    Great, but is there a way we can integrate it into unit tests, that gets run and return the pass / fail?

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      Not yet (with yet being the key word). It isn't really designed for that, though. It is designed to be a quick way to check what your API returns (or even an external API). I would imagine integrating it into unit testing would be a lower priority compared to some of the other features it is still missing.

  •  Před rokem +4

    Could you put an example if the API used token authentication?

    • @jaygis5831
      @jaygis5831 Před rokem +1

      Exactly what I also thought about !

    • @Noceo
      @Noceo Před rokem +2

      Was about to post the same. This video is a good "Getting started" video, but once you add auth (and you almost always do), it seems to get a lot trickier...

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +1

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

    • @ahmedifhaam7266
      @ahmedifhaam7266 Před rokem

      I'm assuming it would be similar to using curl right? the way you do it in postman but the curl code, it probably works here too, getting token and storing it in a variable etc. But will have to try.

    • @Noceo
      @Noceo Před rokem +2

      @ghost mall I still haven’t found a good way to obtain this token. Usually tokens are obtained from a separate auth api and expires within hours. This doesn’t rhyme well on testing. It would be nice to see an example on how to mock a token, if this is at all possible 🤓.

  • @r3gisteel
    @r3gisteel Před 8 měsíci

    I followed the Microsoft tutorial on this but my Visual Studio just tells me the request was completed but there were errors and never pops up with a window showing anything about the response. Any ideas on how to fix this?

    • @IAmTimCorey
      @IAmTimCorey  Před 8 měsíci

      Read the error messages and try to track down what they are telling you.

  • @mhsn27mhsn10
    @mhsn27mhsn10 Před 3 měsíci

    thank you

  • @chaoukiCMCM
    @chaoukiCMCM Před rokem

    What would happen if you do a PUT call, but the person is not in the entries. And what will happen if you do a DELETE call, but the person is also not in the entries?

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      You would see the error result returned in the execution window, just like an end user would if they made those calls.

  • @odumahojorma
    @odumahojorma Před rokem

    wondering how to add bearer tokens and other auth dependencies

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +1

      That is coming with time. They are slowly adding pieces to it. They need to pull the authentication information from a secret location. That way you aren't checking credentials into source control.

  • @philsnewaddress
    @philsnewaddress Před rokem

    It looks like it's far further developed for VSCode that VS and may always be. I havent read too much yet but an essential requirement for me is to be able to pass retrieved auth tokens between calls.

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      That is coming, but it takes a bit. They are just developing this feature now. It will be a part of .NET 8, which releases in November 2023. I don't know if they will have authentication fully handled yet, but they are working carefully towards it. The trick is that you need to pull data from a secret location in order to test authentication. Otherwise, you would be checking credentials into source control.

  • @davidmorrison9641
    @davidmorrison9641 Před 4 měsíci

    How would you send a bearer token using http docs? I'm not having much luck with that..

    • @davidmorrison9641
      @davidmorrison9641 Před 4 měsíci

      Oops.. figured it out. I have a website that calls the api, and I followed the instructions too closely. I put the url of localhost instead of the url of my api I'm calling. So I created a token variable with the token value under my root url, then I added that header like this: Authorization: Bearer {{token}} . Worked great!!

  • @rvrunkillyow716
    @rvrunkillyow716 Před 10 měsíci

    is this feature applicable in visual studio code sir? thanks

    • @IAmTimCorey
      @IAmTimCorey  Před 10 měsíci

      Changes to Visual Studio don't affect VS Code because they are two different systems. VS Code can work with http files, though.

  • @EliasLoveL
    @EliasLoveL Před rokem

    Very Cool Tim.😊👍 But how we can test endpoints with passing a jwt token to authenticate and authorize someone if they have access to retrieve data from an action method ? Can this be done in http files if so please cover that in another video

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +1

      Not automatically yet. They are working on it, though. They need to pull authentication data from a secret location, though, so you aren't checking credentials into source control.

    • @EliasLoveL
      @EliasLoveL Před rokem

      @@IAmTimCorey Thank you 😍😍

  • @neralem
    @neralem Před rokem +1

    Whats the benefit over using Postman?

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +1

      It is checked into source control, it is sharable among the team, it is a quick way to run a test of the API, it is simple, etc. There is still definitely a place for Postman, though.

    • @douglashudson4706
      @douglashudson4706 Před 25 dny

      @@IAmTimCorey It's a cool feature but if Postman is already being used to test in non-local environments, it feels a little like I'm having to repeat myself having to define that test twice.

  • @jashankumar6214
    @jashankumar6214 Před rokem

    Hi tim
    When the monthly pass will be open

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      It will be a while. It was open recently. You can email help@iamtimcorey.com to see if you can get access early. No promises, though.

  • @dotnetdevni
    @dotnetdevni Před 9 měsíci

    but ur not really unit testing they need bring asserts in and this woulr be brilliant

    • @IAmTimCorey
      @IAmTimCorey  Před 9 měsíci

      That's not what we are doing here. Unit testing is done in a unit testing project. This is for testing what you are building as you build it or verifying what data gets returned, etc. If you did want to call it a test type it would be an end-to-end test, since this actually runs the full process.

  • @wassollderscheiss33
    @wassollderscheiss33 Před 8 měsíci

    That feature is near useless.