Built in REST CLIENT (.http/.rest) file in Visual Studio 2022 | Best way to test the API

Поделиться
HTML-код
  • Опубликовано: 25 июл 2024
  • Visual Studio 2022 has a built-in REST Client to test the API or Microservices. This can be done easily by adding a new file with the .http/.rest extension.
    The .rest/.http is a special file in visual studio 2022 v17.5 and has a preview window also.
    We can test multiple APIs from a single http/rest file. After using this .http/.rest file there would not be any need of using Postman, swagger, or any other external tool.
    This is also called as API development inner-loop.
    Chapters:
    00:00 Introduction to built-in rest tool in visual studio 2022
    00:41 Setting up the sample application.
    01:51 Setup the .rest/.http file in visual studio
    03:17 Test and debug the HTTP GET API using .http file in visual studio
    06:06 Pass the data in the URL using .http/.rest file
    07:37 Test and debug the HTTP POST API using .http file
    08:19 Pass the headers in the HTTP call using .http file
    11:15 Pass Authorization header in the HTTP call
    11:22 Test the HTTP PUT API using .http file
    12:37 Add comments in .http file
    13:45 Variables in .http/.rest file
    Code repository: github.com/nitishwebgentle/bu...
    #visualstudio2022 #BuiltInRestClientInVisualStudio #nitishkaushik
  • НаукаНаука

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

  • @nitish.kaushik
    @nitish.kaushik  Год назад

    *Not currently supported in the Visual Studio HTTP Editor*
    Optional HTTP Method
    Request line that spans more than one line
    Named Requests
    Dynamic variables
    Environment files
    Specify file path as body of the request
    Mixed format for body when using multipart/form-data
    GraphQL requests
    cURL request
    Copy/paste as cURL
    Request history
    Save response body to file
    Certificate based authentication
    Prompt variables
    System variables
    Customize response preview
    Per-request settings

  • @LlamaNL
    @LlamaNL Год назад +3

    Great stuff dude, i noticed a similar feature in Rider and hoped it would get ported to VS and now it is!

  • @dianajdanj
    @dianajdanj Год назад +5

    Nice! Next they need to provide a way to also verify expected results, besides unit tests.

  • @JeffreyLimauro
    @JeffreyLimauro Год назад

    Great stuff. Thanks for the tutorial!

  • @akhilendushukla6690
    @akhilendushukla6690 Год назад

    Very nice feature of VS2022.Thanks for the new feature updates

  • @sayedha
    @sayedha Год назад

    Thanks for the video!

  • @sanjgunetileke8836
    @sanjgunetileke8836 Год назад

    Awesome, thank you!

  • @aikidoshi007
    @aikidoshi007 Год назад

    Very nice, thanks!

  • @michaelrockwell3404
    @michaelrockwell3404 Год назад +2

    It is nice to see that Visual Studio is adding new capabilities to easily test API endpoints. I use RESTful endpoints in many of my applications and it certainly is encouraging that Microsoft is building API testing capabilities into the IDE experience. This is a start, and I am sure that Microsoft will eventually get on par with Swagger and Postman.

    • @nitish.kaushik
      @nitish.kaushik  Год назад +1

      Exactly. This would be a game changer in testing the endpoints.

  • @MB-nw5sz
    @MB-nw5sz Год назад

    Great information, thank you

  • @johnwarner9522
    @johnwarner9522 Год назад

    Great video. Thank you. Do you know if there is a way to change the timeout?

  • @juancarloshb5
    @juancarloshb5 Год назад +1

    Hello thanks for great content! , does it has enviroment variables feature ?, where i can find documentation?

  • @JagdishJ666
    @JagdishJ666 Год назад

    Excellent topic

  • @kaushikbhadani-tt4bm
    @kaushikbhadani-tt4bm Год назад

    Hi Kaushik. Your tutorial is very very helpful. Thank you for sharing your knowledge!!

  • @rokckerzzzz6080
    @rokckerzzzz6080 Год назад

    Very informative video. Thanks

  • @siddharthazedia1544
    @siddharthazedia1544 Год назад

    Thank you for being aware it never knew before

  • @thomasleberre1119
    @thomasleberre1119 Год назад +4

    Is there a nice way to handle the call an authentication route with a username/password and store the given token ?

  • @coding-gemini
    @coding-gemini Год назад

    Excellently explained, thanks Nitish, subscribing to your channel

  • @divyasingh6981
    @divyasingh6981 Год назад

    Thank you 😊

  • @kidsvideoforkids2321
    @kidsvideoforkids2321 Год назад

    very helpful thanks sir

  • @simpsonkamonere3926
    @simpsonkamonere3926 Год назад

    Good job

  • @dotnetdevni
    @dotnetdevni Год назад

    Can you do assertations in this expected to what is produced?

  • @vishalsvits
    @vishalsvits Год назад

    Very helpful , thanks

  • @ChristianHolmMaagaard
    @ChristianHolmMaagaard Год назад +1

    Is multipart/form-data supported? 🤔

  • @VijayKumar-jc8nd
    @VijayKumar-jc8nd Год назад

    Its a nice video. Is there any automation testing for the http file you have created. Instead of running each link. Can we automate it for testing

  • @rogerswetnam1416
    @rogerswetnam1416 Год назад +2

    Great - thanks! Having trouble adding an x-api-key to the header for for authentication - how would this be done?

    • @nitish.kaushik
      @nitish.kaushik  Год назад +4

      Thanks for the feedback. Here is the sample code to pass the token in the header.
      @baseUrl = localhost:7289
      @token = dascddasdsfsfafdsfdsafd....asdfdfdasf
      POST {{baseUrl}}/api/employee
      Content-Type: application/json
      Authorization: Bearer {{token}}
      {
      "id": 0,
      "name": "nitish kaushik updated",
      "email": "testing@sample.com"
      }

    • @shyamkumarrana5856
      @shyamkumarrana5856 Год назад

      How to pass apikey in header

  • @OeHomestead
    @OeHomestead Год назад

    Been doing it this way for a very long time using an extension.

    • @nitish.kaushik
      @nitish.kaushik  Год назад +1

      That's great. Would you like to share the extension name or URL with us.

  • @dotnetdevni
    @dotnetdevni Год назад

    Is there a api test runner comming soon that would be awsome.

  • @danielboucher3266
    @danielboucher3266 Год назад +1

    Terrific overview, and I will start using this immediately. Question: What are the differences between using ".http" vs ".rest"? Are they identical, or is there a benefit to using one over the other?

    • @nitish.kaushik
      @nitish.kaushik  Год назад

      Hey @Daniel thankyou for the feedback. There is no difference in both the extensions. You can use any one of them in your project.

    • @danielboucher3266
      @danielboucher3266 Год назад

      @@nitish.kaushik Thank you for clarifying. It's interesting they chose to support two extensions with no differences.

  • @AlexanderKollin
    @AlexanderKollin Год назад

    Very interesting video. How is it possible to send end get cookies?

  • @EDA.architect
    @EDA.architect Год назад

    If you want to replace postman, the "Thunder client" extension is a great open-source option.

  • @Yarkendar
    @Yarkendar Год назад

    What about chaining request ?

  • @kaushikbhadani
    @kaushikbhadani Год назад

    Thank you Nitish Kaushik. Your tutorial is very helpful. If possible please create Azure tutorial series.

    • @nitish.kaushik
      @nitish.kaushik  Год назад

      Thankyou for sharing feedback. I am planning to cover Azure.

  • @yasserosuna7101
    @yasserosuna7101 Год назад

    Any way to convert class to Json?

  • @TheCMajor9th
    @TheCMajor9th Год назад +1

    this seems okeish , for very simple stuff , how would you test authentication? , how would that work with nswag ? and also lets not forget frontend end devs .lets say you have frontend devs who need the api documentation thats swagger, to build by hand or with automation the services to API what would you provide to them ? i think in terms of development that helps only the backend dev.

    • @nitish.kaushik
      @nitish.kaushik  Год назад

      Great observation. Authentication is possible in .http/.rest file also by passing the Authorization header with the correct token.
      However, I agree with the requirement of doc front-end developers.
      But don't forget this is just the beginning of the rest client in visual studio and there will definitely be some great improvements in the future as well.
      *Thank you for sharing your thoughts on this topic with us.*

  • @haxkalibrr
    @haxkalibrr Год назад

    Very nice presentation of the feature.
    Does anyone know whether its possible to use variables across files?
    For example, to import a JWT token defined in a specific file into another file.

    • @nitish.kaushik
      @nitish.kaushik  Год назад

      Thankyou for sharing your feedback. I was also having the same question but seems like this feature (importing var from other file) is not possible in this release.
      But lets see how it goes in upcoming releases.

    • @haxkalibrr
      @haxkalibrr Год назад

      @@nitish.kaushik Cool. Thanks for investing your time to inform us about this. The feature shows great promise.

  • @MarkInChicago
    @MarkInChicago Год назад +1

    Terrific content and presentation! Let me add a couple of suggestions to make your videos perfect. Watching you type is distracting because my eye is trying to focus on the code and listening to your explanation. I would recommend that you skip showing yourself over the video. Second, please remember to talk slowly. Thank you for ccovering this new feature comprehensively.

    • @nitish.kaushik
      @nitish.kaushik  Год назад

      Thankyou Mark for the feedback. I will take care of them in future videos 🙂

  • @JanuszKrysztofiak
    @JanuszKrysztofiak Год назад

    JetBrains IDEs (IntelliJ, Rider, PyCharm, ...) have had this for quite some time.

  • @vitalik3229
    @vitalik3229 Год назад

    This very necessary app for everyone's thanks for quality crack!

  • @ronmodic1187
    @ronmodic1187 Год назад

    Is there a way to pass response data from one call to a second call. this can be done in vscode version example: Authorization: {{authRequest.response.body.token }}

  • @bloodorangegaming
    @bloodorangegaming 8 месяцев назад

    Hi, how to use nested var from json?

    • @nitish.kaushik
      @nitish.kaushik  6 месяцев назад

      Some new features have been added to this feature and now you can set your variables from configuration json file.

  • @rajeshchincholkar1982
    @rajeshchincholkar1982 Год назад

    Nice👍 can you do some learning vdos about microservices.

  • @bithelpfoundation7498
    @bithelpfoundation7498 Год назад

    Hey, can you send me the entire project repo link ? I am new to C# and would want to understand the entire code

    • @nitish.kaushik
      @nitish.kaushik  Год назад +1

      *Here it is*
      github.com/nitishwebgentle/built-in-rest-client-in-visual-studio-2022

  • @nirankarkaushik9549
    @nirankarkaushik9549 Год назад

    Can this feature be used for testing gRPC

    • @nitish.kaushik
      @nitish.kaushik  Год назад

      You can test any endpoint using this feature.

  • @MohammadKomaei
    @MohammadKomaei Год назад

    How to send all requests? (all green play buttons)

    • @nitish.kaushik
      @nitish.kaushik  6 месяцев назад

      As of now you can send the request one by one

  • @sagarkulkarni5356
    @sagarkulkarni5356 Год назад

    Can we use this to test out during DevOps?

    • @nitish.kaushik
      @nitish.kaushik  Год назад

      I dont think so. This only works only on VS 2022.

  • @rvrunkillyow716
    @rvrunkillyow716 10 месяцев назад

    how can i implement this with visual studio code? thanks.

    • @nitish.kaushik
      @nitish.kaushik  10 месяцев назад

      As of now this feature is supported only in Visual Studio.

  • @slowbrain8869
    @slowbrain8869 Год назад

    How to test if the api application is secured with o auth 2.0 , which requires user name and password

    • @nitish.kaushik
      @nitish.kaushik  Год назад

      You can get the token from browser network tab and use the same token here. That will work.

  • @everyonesview
    @everyonesview Год назад +1

    Not yet, pal. Postman & Swagger are much more. How would you handle secure endpoints with say bearer tokens with this new thingy?

    • @nitish.kaushik
      @nitish.kaushik  Год назад +1

      You can pas the token in the header. Just like we are passing content type, in the same way you can pass Authorize header and you can store the token in a variable.

    • @charleswoodruff9013
      @charleswoodruff9013 Год назад

      @@nitish.kaushik Sensitive data shouldn't be hard-coded in the application. This is a security breach.

    • @nitish.kaushik
      @nitish.kaushik  Год назад

      You are right. But this concept is just the beginning. May be there will be some great improvements in future releases.

    • @sayedha
      @sayedha Год назад +1

      We are going to be working to enable using secrets in a secure fashion. Nothing specific to share at this time though. I’m on the team developing this feature.

    • @nitish.kaushik
      @nitish.kaushik  Год назад +1

      Thanks Sayed for your reply.

  • @venkim9078
    @venkim9078 Год назад

    What the heck..how does this replace postman….you are saying that we have to write .net proje t

  • @PedroOliveiraBrasil
    @PedroOliveiraBrasil Год назад

    How to use authorization with APIKey?

    • @nitish.kaushik
      @nitish.kaushik  Год назад +1

      You can pass n number of headers in the request.
      08:19 Pass the headers in the HTTP call using .http file

    • @PedroOliveiraBrasil
      @PedroOliveiraBrasil Год назад

      @@nitish.kaushik Yes, I just included the APIKey and the value in the header and it worked! Thanks.

    • @nitish.kaushik
      @nitish.kaushik  Год назад

      Excellent 👍👍

  • @dtvind
    @dtvind Год назад

    I would say bye bye to your video In title

    • @nitish.kaushik
      @nitish.kaushik  Год назад

      But what is the reason 🤔 ? You don't like the feature?

  • @reefhound9902
    @reefhound9902 Год назад +1

    This is still a child's toy compared to the capabilities of Postman. Environments, scripting, variables, test runner, read data from files, etc. I know you said not to compare with mature tools like Postman but you also said "After using this .http/.rest file there would not be any need of using Postman, swagger, or any other external tool." You can't have it both ways. Either it can do what Postman does or you likely still need Postman.

  • @JakubSK
    @JakubSK Год назад

    Bye bye Visual Studio