Self Help - HTTP Connector (REST) - Use Case
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
- HTTP connector (REST): GET Request method.
- View a ticket method of the Service Manager REST API.
Procedure
Overview
The implementation of the use case is performed in several phases:
- Phase 1: Create and configure the form for collecting information
- Phase 2: Configure the HTTP connector (REST) to retrieve information on the ticket in Service Manager
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.
See the detailed procedure
2. Add a simple input field called RFC Number.
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.
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.
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.
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.
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.
- 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.
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.
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.
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.
2. Click Finish.
The condition indicating a failed process will appear in the procedure.
3. Create a Page step after the new condition. Name it error.
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.
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.
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.
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.
3. Click Finish.
The condition indicating that no result was found will appear in the procedure.
4. Create a Page step after the new condition. Name it No result.
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.
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.
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.
2. Select the Content tab in the Description pane of the step.
3. Write a message informing users that the process was successful.
- 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
Phase 4: Check that the procedure works correctly
1. Run the procedure.
2. Enter the ticket number using the form.
3. Check that the relevant message appears if the process fails.
4. Check that the relevant message appears if the ticket does not exist.
5. Check that the information on the ticket is correctly displayed if it exists.