blog.atwork.at

news and know-how about microsoft, technology, cloud and more.

Use Visual Studio Code and the REST Client extension for testing HTTP Requests

Are you using tools as Telerik Fiddler or Postman for testing HTTP Requests? Well, if you are already working with Visual Studio Code, try out the cool REST Client extension!

My colleague Christoph showed me this cool extension for executing HTTP requests directly from VS Code quickly. Simply install the REST Client extension: Press F1, type ext install then search for rest-client as shown in the following screenshot.

image

(Check out the useful Run Code from Visual Studio Code extension as well...)

Once installed, create a file.http and insert your HTTP REST calls into that file as here:

image

You can do quick HTTP operations as...

GET https://example.com/api/function1?name=Joe HTTP/1.1
###
POST https://example.com/api/function2 HTTP/1.1
content-type: application/json
{
"name": "Joe",
"time": "Sun, 15 Apr 2018 10:00:00 GMT"
}

Select the HTTP Request and press Ctrl + Alt + R (or use the context menu as shown above). This opens a REST Response tab showing the response of the web service and the time used. The extension also has support for Authentication built-in (Basic Auth, Digest Auth, SSL Client Certificates, Azure Active Directory).

If the service could not be reached, you get a corresponding notification "Connection is being rejected" in the bottom right corner...

image

...or otherwise the service response as shown in the screenshot above. You can save the response with the Save icons in the right top bar as well:

image

Then, a notification is inserted and shows buttons to open and to copy the file path.

image

Very useful! Hope you like the REST Client extension as much as I do!

Comments (2) -

  • RajeshN

    4/30/2018 12:38:28 PM |

    Great post! Wow, this seems to be an awesome extension and very useful too. Thanks much for sharing the configuration steps and more helpful information about this extension. Great help! Thank you.

    Best Regards
    RajeshN, Nous Infosystems

  • Toni Pohl

    5/12/2018 7:38:45 PM |

    Just as a reminder: Add the Content-Type: application/json and a BLANK line after the headers for the BODY in the .http file as in the sample here:

    ### first request
    POST https://prod-22.northeurope.logic.azure.com:443/workflows/someaddress...
    Content-Type: application/json

    {
        "email": "john.doe@contosoe.com",
        "firstname": "John",
        "lastname": "Doe",
        "request": "some data"
    }

    ### next request...


    For other content-types see
    docs.microsoft.com/.../logic-apps-content-type

Loading