DEV Community

Cover image for Leverage ServiceNow REST API: Integrate & Create Records Selectively
Sophia Semga
Sophia Semga

Posted on

Leverage ServiceNow REST API: Integrate & Create Records Selectively

ServiceNow offers a powerful tool for integrating with external applications: the REST (Representational State Transfer) API. This inbound web service allows external applications and clients to interact with data within your ServiceNow instance in a controlled manner.

Think of it as a set of well-defined functions that enable you to send requests and receive responses from other applications using HTTP protocols.
Common REST HTTP methods include:
• GET: Retrieve data from a third-party application.
• PUT: Update data within a third-party application.
• POST: Create new data within a third-party application.
• DELETE: Delete data from a third-party application.
• PATCH: Partially update data within a third-party application.

Use Case: Creating a ServiceNow Record from Another Application with Selective Field Copying

This scenario demonstrates how to create a ServiceNow record from another application while including specific fields from being copied into the ServiceNow record.

1. Setting Up the Inbound Web Service

•Navigate to Web Services > Inbound. This is where you define how external applications can interact with your ServiceNow data.
•Fill in the Label Name (a user-friendly name for your integration).
Select the Target Table where the data will be stored (e.g., Incident table).
•Under Web Service Fields, define the fields you'll receive from the third-party application. These are the fields required to create a record in ServiceNow (e.g., caller, short description).
•Click Create.

Image description

2. Configuring the Transform Map

•Upon creation, a Transform Map is generated. This map translates data from the source table (where the third-party application sends data) to the target table (the ServiceNow table you selected).
•Click on Automapping Assist to automatically map fields from source to target.
Review and adjust the mappings as needed.
•Click Save to save the transform map.

3. Testing the Web Service

•Locate your newly created inbound web service in the Application Navigator.
Image description

•Under Related Links, click Explore REST API. This interface allows you to test the web service before integrating with the third-party application.
•On the Explore REST API interface, you'll see the staging table name and a request body section.
Image description

•In the request body, enter test data for the fields you defined earlier.

Image description

•Click Send.
Remember, request formats for ServiceNow REST APIs are always in JSON format.

4. Verifying Successful Test

•A successful test will return a status code of 201 (Created).
Image description

•The response body will display a newly created test record.
Image description

•Double-check by navigating to Incident > Open to confirm the test record exists.

Image description
Image description

5. Integration with Third-Party Application (HoppScotch)

🔗:https://hoppscotch.com/

Now, let's integrate your ServiceNow instance with a third-party application called HoppScotch to create records directly from HoppScotch.

Configuration on HoppScotch

•Use the POST method as you're creating a new record.

Image description

•In the Request URL, copy the method URL from the ServiceNow REST API Explorer. This URL defines the resource where data will be posted.

Image description

•For Authorization, select Basic Auth and enter your ServiceNow username and password. This ensures secure communication between applications.

Image description

•Under Headers, set the Content-Type to application/json.

Image description

•In the Body section, copy and paste the request body data from the ServiceNow REST API Explorer. This data defines the information to be included in the new record.

Image description

•Click Send.

6. Confirmation and Verification

•A successful creation will return a status code of 201 (Created).
The response body will contain details about the import set, staging table, and the newly created ServiceNow record.

Image description

•Navigate back to your ServiceNow instance under Incident > Open to confirm the record was successfully created.

Image description
Image description

Conclusion

Congratulations! You've successfully utilized ServiceNow's REST API to create a record in your instance through a third-party application.
🎊🎊

Expand Your Toolkit: Exploring Additional REST API Clients

Beyond HoppScotch, several other tools offer functionalities similar to API testing, development, and collaboration. Here are a few popular options:

•Insomnia:[https://insomnia.rest/]
•Paw: [https://paw.cloud/]
•Postman:[https://www.postman.com/]
•SwaggerHub: [https://swagger.io/tools/swaggerhub/]


Further Learning:

For a deeper dive into ServiceNow REST API functionalities and methods, refer to the ServiceNow product documentation on REST APIs.
•ServiceNow REST API: https://docs.servicenow.com/bundle/washingtondc-application-development/page/integrate/inbound-rest/concept/c_RESTAPI.html

•ServiceNow REST API reference: https://docs.servicenow.com/bundle/washingtondc-api-reference/page/build/applications/concept/api-rest.html

Top comments (0)