ballerinax/servicenow Ballerina library

1.5.1

Overview

This is a generated connector for ServiceNow REST API Quebec version OpenAPI Specification.

ServiceNow provides extensive access to instances through a set of RESTful APIs.

Prerequisites

Before using this connector in your Ballerina application, complete the following:

  1. Create a ServiceNow instance (If you already have one, you can use that).

  2. Obtain tokens - Follow this guide.

Quickstart

To use the ServiceNow connector in your Ballerina application, update the .bal file as follows:

Step 1: Import connector

Import the ballerinax/servicenow module into the Ballerina project.

Copy
import ballerinax/servicenow;

Step 2: Create a new connector instance.

You can now make the connection configuration using either one of the following, and initialize the connector with it.

  • The OAuth2 refresh token grant config.
Copy
ClientConfig clientConfig = {
    auth : {
        refreshUrl : "<YOUR INSTANCE URL>/oauth_token",
        refreshToken : "<REFRESH TOKEN>",
        clientId : "<CLIENT ID>",
        clientSecret : "<CLIENT SECRET>"
    }
};

ervicenow:Client servicenowClient = check new (configuration, serviceUrl = <YOUR INSTANCE URL>);
  • The bearer token config.
Copy
ClientConfig clientConfig = {
    auth : {
        token : "<YOUR ACCESS TOKEN>"
    }
};

ervicenow:Client servicenowClient = check new (configuration, serviceUrl = <YOUR INSTANCE URL>);
  • The credentials config (with username and password).
Copy
ClientConfig clientConfig = {
   auth : {
       username: "<USERNAME>",
       password: "<PASSWORD>"
   }
};

ervicenow:Client servicenowClient = check new (configuration, serviceUrl = <YOUR INSTANCE URL>);

Step 3: Invoke connector operation

  1. Now you can use the operations available within the connector. Note that they are in the form of remote operations. Following is an example on how to insert a record to a table using ballerinax/servicenow connector.
Copy
public function main() returns error? {
    string tableName = "incident

    json payload =  {
        "short_description":"Unable to connect to office wifi",
        "assignment_group":"287ebd7da9fe198100f92cc8d1d2154e",
        "urgency":"2",
        "impact":"2"};

    json response = check servicenowClient->createRecord(tableName, payload);
}
  1. Use bal run command to compile and run the Ballerina program.

Import

import ballerinax/servicenow;Copy

Metadata

Released date: over 1 year ago

Version: 1.5.1

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.4.1

GraalVM compatible: Yes


Pull count

Total: 2452

Current verison: 306


Weekly downloads


Source repository


Keywords

Support/Customer Support

Cost/Freemium


Contributors

Other versions

See more...