Skip to content
background-image background-image

First integration

In this example, we will walk you through a simple case where, we'll show you how to use a REST API bound to JavaScript mapping connector. You'll send a request with a query string using the GET method. The JS mapper will process the input, and the API will then return the output data at the specified endpoint.

Input parameters:

  • Language parameter in the form YourLang ("sk" for the Slovak language, "cz" for the Czech, and "en" for the English language)
  • Name parameter in the form YourName

Output data on the Rest API endpoint:

  • For English: Hi < Name >!,
  • For Czech: Ahoj < Name >!,
  • for Slovak: Ahoj < Name >!,
  • for another language return a message: "The selected language is not in the menu, try to select another language (for example: en, cz or sk)."
  • In case a parameter Name is not provided, return the value "Please try again and enter a name".

Try the Trial integration

After logging in to the Trial, a company called Sample for Your Name is ready for you.

Help_Get_started_Sample_Company

Click on the company name to display a list of Tasks - you will see a Task named Hello.

Help_Get_started_Short_Tasks

Open the Task, and you will see the configuration - one step with the JS Mapper connector used, which is connected to the Endpoint with the GET method.

Help_Get_Started_Task_view

If you want to see the details of Step #1, click on the button with the pencil symbol. Do not edit anything here yet. Don't worry, your time will come.

Now click on Endpoints in the left side panel, and you will see a list of Endpoints - in the Trial version, you will find a predefined endpoint called First endpoint.

Help_Get_started_Short_First_Endpoint

Open the endpoint to view endpoint settings detail. On the GET tab, you will see the connection to the Hello task and its mapping.

Help_Get started_Short_Endpoint_GET

Copy the endpoint link from the top of the screen, open a new browser window, and paste the copied URL.

Help_Get_started_Short_Endpoint_URL

At the end of the inserted URL, add the Language and Name parameters in the form, for example:

?YourLang=en&YourName=John

The final URL may look like this:

https://trial.integray.app/api/endpoint/trial-123/first-group/first-endpoint?YourLang=en&YourName=John

Confirm the URL in the address bar of your web browser and let Integray do its work. The result is a running Task called by the Endpoint and the outcome might look like as follows:

[{"ResponseText":"Hello John!"}]

Now let's make a small adjustment.

In the Endpoint section, on the GET tab, check the Include system data in response button. Save the changes and click the Publish button. This will cause the system data will be displayed in the resulting outcome.

Help_Get_started_short_Include_system_data_in_response

Change the Language and Name parameters. Instead of "en" use "cz" (for the Czech language) and choose another name instead of "John".

The final version of the parameters may look like this:

?YourLang=cz&YourName=Adam

The final URL may look like this:

https://trial.integray.app/api/endpoint/trial-123/first-group/first-endpoint?YourLang=cz&YourName=Adam

The outcome will look as follows:

{
    ID: "b3ed293a-3d82-4ff5-b119-18e73352eff7",
    Status: "FinishedSuccess",
    Link: "https://trial.integray.app/home/company/123/task/220?taskRunID=60791",
    Message: null,
    Result: [
        {
            ResponseText: "Ahoj Adam!"
        }
    ]
}

Now, delete the entire Name parameter from the URL.

The final version of the parameter may look like this:

?YourLang=cz

The resulting URL will look like this:

https://trial.integray.app/api/endpoint/trial-123/first-group/first-endpoint?YourLang=cz.

The instruction will appear in the outcome, prompting you to input your name and make another attempt.

{
    ID: "b3ed293a-3d82-4ff5-b119-18e73352eff7",
    Status: "FinishedSuccess",
    Link: "https://trial.integray.app/home/company/123/task/220?taskRunID=60791",
    Message: null,
    Result: [
        {
            ResponseText: "Please try again and enter a name"
        }
    ]
}

Congratulations, you have now successfully completed this basic example. If you feel ready to take the next steps, we encourage you to try your own configuration of this Task. You can also visit our community forum, where you will find a space to discuss, share experiences, and get support from other users. For more inspiration and configuration examples, check out our Example Library for various other useful examples. You also have the option to explore our Knowledge Base section to learn more about Integray.