Login

Please login for an individual price calculation.

Forgot Password?

Always stay up to date

With our e-mailings you will receive regular information about products, events, services and Balluff.

REGISTER AS A COMPANY

We will check whether you already have a customer number with us in order to link your new online account with it.

Register
Products
Industries and Solutions
Resources
Company
Version 3.0
·
Last edited on 2024-05-21

REST-API commands via Visual Studio Code and Thunder Client

1. Introduction

This guide shows how to send HTTP commands to a REST-API client using the Thunder Client plug-in in Visual Studio Code.

2. Visual Studio Code Plug-In "Thunder Client"

Attention:
In principle, none of the actions can be undone throughout the plug-in.
Changes are only valid after saving (CTRL + S).

2.1. Installation Plug-In

Click on the "Extensions" tab on the left-hand side and search for "Thunder Client".
Click on the blue "Install" button to install the extension, which will also appear as a separate tab on the left-hand side.

If the tab for the Thunder Client does not appear, it is due to the restricted mode when restarting:

Click on the Restricted Mode field and then confirm under "Trust"


2.2. Use

  1. List of recent commands

  2. Library of commands: Collections
    Predefined commands can be imported or exported into packages here.






    Please note: The free version can only contain 50 commands per collection.

  1. Type of command: GET, POST, DELETE, etc.



  2. Header customization
    Additional header information can be added to the free field:




    Example: Send cookie in the header information:
    Bild

  3. Authentication
    Additional information on different authentication methods can be added here

    Ex: Bearer Token


    Ex: Basic Authetification
    Is transmitted in the header in the format usaername:password in Base64 format.
    Attention: cannot be used for user login!


  4. Body information with different data formats



    Sending files:




  5. Sending the command


  6. Response to the command
    Here is an example of the response to a login process.

    1. Direct response:


    2. Header information


    3. Cookies (separated):


    4. Analyze request:

3. Variables

There are three types of variables:
Path variables: {{variable}}
Environment variables: {{variable}}
System variables: {{#Variable}}


Environment variables can be defined in the Env tab.



Example: Login with environment variables

  1. Log in and retrieve bearer token



  2. Customize environment variable:


    Attention: Do not forget to save!

  3. Use variable in POST command:

Attention:
The values of the variables are assigned in sequence.
If a variable exists more than once (no check of the editor!), the value of the lowest variable is always assigned,
Example: Here the variable PortNumber is assigned the value 1.

3.1. Path variables

Path variables are displayed between a single curly bracket.
These can be assigned to a command in the Query tab.

3.2. Environment variables

Environment variables can be defined in the Env tab.



Example: Login with environment variables

  1. Log in and retrieve Bearer Token



  2. Customize environment variable:


    Attention: Do not forget to save!

  3. Use variable in POST command:

Attention:
The values of the variables are assigned in sequence.
If a variable exists more than once (no check of the editor!), the value of the lowest variable is always assigned,
Example: Here the variable PortNumber is assigned the value 1.


Only one variable list can be active at a time.
You can swap between the variable tables at the bottom of the development environment:

3.3. System variables

System variables are displayed in a double curly bracket and also have a hash {{#variable}}.



Example: Setting the system time using a system variable


Example: Randomly generated values for names, strings or emails

3.4. Automation of processes

A distinction is made between pre-requests and POST requests, which can be sent automatically to a certain extent.
Javascript programs can also be played before or after.

Pre-requests are commands and requests that can be sent before the actual command is sent.

Example: Query whether you are logged in. If not, login is executed.


Scripting example:

Post-requests are sent or processed after the actual command has been executed.

Example: Setting variables.

Example: Checking the command response.

Example scripting: Evaluate response.

Scripting


4. Collections

Predefined collections or YAML files can be inserted via Import.
Each collection can be provided with global settings that affect every command and folder.

A base path can be specified under Options, which is placed in front of each command in the collection.
BaseURL and BasePath are stored here.
Example:
192.168.1.1/api/balluff/v2
The rest of the specific command is defined by the respective command input.

If external APIs are loaded via a YAML file, for example, variables may have to be adapted in the command:
As here, an additional {} must be inserted so that this is recognized as a variable of the Env table.


Attention: Each collection can only contain 50 commands in the free version!

Energy consumption labeling
Energy consumption labeling

EPREL - European Product Database for Energy Labeling

Free sample product

In order to add a free sample product to the cart we will need to remove all the normal products from the cart. Are you sure you want to continue