Self Help - HTTP Connector (REST) - Use Case

Last modified on 2023/08/09 14:22

  To help you set up this use case, you can download the relevant documentation and sample project. Open url.png See List of files to download

This use case enables you to search for information on a ticket in Service Manager using its ID by running a Self Help procedure.

Objects used

Procedure
     HTTP Connector - Get Method - Use case - Procedure.png

Overview

The implementation of the use case is performed in several phases:

Prerequisites

1. Contact your administrator for the credentials of the Service Manager account dedicated to the Service Manager REST API.

Phase 1: Create and configure the form for collecting information

Step 1: Create the form

The form enables users to enter the reference of the ticket whose information they want to retrieve.

1. Create a new form in the Resources folder of your Self Help project. Name it Data.

     Open url.png See the detailed procedure

2. Add a simple input field called RFC Number.

          HTTP Connector - Get Method - Use case - Form.png
 

Step 2: Add the form to a procedure step

1. Create a new procedure in your Self Help project. Name it Get ticket information.

2. Create the first step, i.e. a Page step. Name it Entering the RFC Number.

3. Click and drag the Data form to the step.

          HTTP Connector - Get Method - Use case - Step Input information.png

Phase 2: Configure the HTTP connector (REST)

Step 1: Create a new Connector resource

You create a Connector resource in order to send the value entered by users in the form to the Service Manager REST API. It uses the HTTP connector (REST) and the GET Request method.

1. Create a new Connector resource in the Resources folder of your Self Help project.

  • Select the connector, HTTP connector (REST).
  • Click Next.
          HTTP Connector - Get Method - Use case - Add HTTP connector.png

2. Select the GET Request method.

Note: Do not define the default parameters specific to the method. They will be defined when the connector is added to the procedure.

          HTTP Connector - Get Method - Use case - General parameters.png

3. Click Next and click Finish.

The new Connector resource will be added to the Resources folder.
 

Step 2: Add the resource to a procedure step

1. Create an Action with Switch step after the Entering the RFC Number step. Name it Get information.

Two branches will be created.
      HTTP Connector - Get Method - Use case - Step Get information.png

2. Click and drag the new Connector resource to the Get information step and click Next.

The window for configuring the connector parameters will appear.

3. Define the general connector configuration and click Next.

Caution:

  • You must add double quote marks around each parameter value (" ").
  • Do not define the input parameters specific to the GET Request method.
  • URL: Specify the URL that will call the View a ticket method of the Service Manager REST API as shown below.
    Replace:
    • {your_server} with the server URL
    • {your_account} with the Service Manager account used
    • {resource_name} with the resource that is called: requests
    • {identifier} with the ticket ID stored in the RFC Number field in the Data form: Data.rfc_number

https://{your_server}/api/v1/{your_account}}/{resource_name}+{identifier}

      example

"https://your_company.easyvista.com/api/v1/40000/requests/"+Data.rfc_number

  • Authentication: Enter BasicPre.
  • Login / Password: Enter the login and password of the Service Manager account dedicated to the Service Manager REST API.

          HTTP Connector - Get Method - Use case - Input parameters.png

4. Specify the output parameters of the method.

  • Select the New variable checkboxes next to the result and error output variables to create them.
  • Click Finish.
          HTTP Connector - Get Method - Use case - Output parameters.png

5. Click OK in the Parameters Refactoring window.

The GET Request method of the HTTP connector (REST) will be associated with the Get information step. You can now search for ticket information in Service Manager.

Phase 3: Define the conditions for testing the call to the connector

You must add a condition to the error output variable of the GET Request method. If the variable is not null, this means that the process failed. If the variable is null, this means that the process was successful. You must then add a condition to the result.body.message output variable to check the presence of the message, Resource not found.
 Open url.png See the description of return codes
 

Step 1: Add a condition to check if the call to the connector failed

1. Define the condition that will show a failed process, indicated by a non-null value in the error output variable.

  • Double-click the <cond.> branch of the Get information step.
    The window for defining the condition will appear.
  • Select the error output variable.
  • Select the is not null operator.
           HTTP Connector - Get Method - Use case - Add condition for Error.png

2. Click Finish.

The condition indicating a failed process will appear in the procedure.

          HTTP Connector - Get Method - Use case - Condition for Error added.png

3. Create a Page step after the new condition. Name it error.

          HTTP Connector - Get Method - Use case - Add condition for Error - To display message.png

4. Select the Content tab in the Description pane of the step.

5. Write a message informing users that the process failed and display the error stored in the error output variable.

          HTTP Connector - Get Method - Use case - Message - Error.png
 

Step 2: Add a condition to check if the call to the connector was successful with no results returned

The result output variable contains the JSON object of the View a ticket method. If the search does not return any results, the result.body.message output variable will contain the message, Resource not found.
 Open url.png See Description of the JSON object of the View a ticket method

1. Create another conditional branch after the Get information step.

  • Right-click the Get information step.
  • Select Insert a Step > Add a Branch from the contextual menu.

          HTTP Connector - Get Method - Use case - Add branch condition for Success without record.png

2. Define the condition that will show that no record was found, indicated by the presence of the message, Resource not found in the result.body.message output variable.

  • Double-click the new <cond.> branch.
    The window for defining the condition will appear.
  • Select the result.body.message output variable.
  • Select the contains operator and enter the value, Resource not found.

Caution: You must add double quote marks around each parameter value (" ").

          HTTP Connector - Get Method - Use case - Add branch condition for Success without record - Add condition.png

3. Click Finish.

The condition indicating that no result was found will appear in the procedure.

          HTTP Connector - Get Method - Use case - Branch condition for Success without record added.png

4. Create a Page step after the new condition. Name it No result.

          HTTP Connector - Get Method - Use case - Add branch condition for Success without record - Add condition without record.png

5. Select the Content tab in the Description pane of the step.

6. Write a message informing users that the search did not return any results.

  • The Data.rfc_number variable indicates the ticket number specified by the user in the Data form.

          HTTP Connector - Get Method - Use case - Message - Success without record message.png
 

Step 3: Process the results if the call to the connector was successful and the search returned results

The result output variable contains the JSON object of the View a ticket method. All of the ticket information returned is stored in the result.body output variable.
 Open url.png See Description of the JSON object of the View a ticket method

1. Create a Page step after the default branch of the Get information step. Name it Success.

          HTTP Connector - Get Method - Use case - Add condition - Success with records.png

2. Select the Content tab in the Description pane of the step.

3. Write a message informing users that the process was successful.

Best Practice icon.png  To display a specific item of information on the ticket, add the relevant field after the result.body variable.

example  Display the recipient's name ==> result.body.RECIPIENT.LAST_NAME

  • Insert a table to display the results.
  • Enter the information to be displayed on the ticket in the first column, i.e. ticket number, creation date, recipient name, status.
  • Enter the expression corresponding to the value to be displayed in the second column.
    • Ticket number: result.body.RFC_NUMBER
    • Creation date: result.body.CREATION_DATE_UT
    • Recipient name: result.body.RECIPIENT.LAST_NAME
    • Status: result.body.STATUS.STATUS_{code_language}
      Replace {code_language} with the relevant language code.

      example    result.body.STATUS.STATUS_FR

          HTTP Connector - Get Method - Use case - Success with records - Values of information to display.png

Phase 4: Check that the procedure works correctly

1. Run the procedure.

2. Enter the ticket number using the form.

          HTTP Connector - Get Method - Use case - Test procedure - Entry informations.png

3. Check that the relevant message appears if the process fails.

          HTTP Connector - Get Method - Use case - Test procedure - Error process.png

4. Check that the relevant message appears if the ticket does not exist.

          HTTP Connector - Get Method - Use case - Test procedure - Success without record.png

5. Check that the information on the ticket is correctly displayed if it exists.

          HTTP Connector - Get Method - Use case - Test procedure - Success with record.png

List of files to download

Tags:
Powered by XWiki © EasyVista 2022