ServiceNow Component

Available as of Camel 2.18

The ServiceNow component provides access to all of ServiceNow REST API

Maven users will need to add the following dependency to their pom.xml for this component:

	<dependency>
    	<groupId>org.apache.camel</groupId>
    	<artifactId>camel-servicenow</artifactId>
    	<version>${camel-version}</version>
	</dependency>

URI format

    servicenow://instanceName?[options]

 

Options

Name

Default Value

Description

userName

null

The user name to use for authentication

passwordnullThe password to use for authentication
oauthClientIdnullOAuth2 client id
oauthClientSecretnullOAuth2 client secret
oauthTokenUrlhttps://incenceName.service-now.com/oauth_token.doThe OAuth2 token url
apiUrlhttps://incenceName.service-now.com/api/nowThe ServiceNow API url
tablenullThe default table, can be overridden by header CamelServiceNowTable
excludeReferenceLinkfalseTrue to exclude Table API links for reference fields
suppressAutoSysFieldfalseTrue to suppress auto generation of system fields
displayValuefalse

Return the display value (true), actual value (false), or both (all) for reference fields (default: false)

inputDisplayValuefalseTrue to set raw value of input fields
modelsnullDefines the default model to use for a table i.e models.incident = my.company.model.Incident
mapper ServiceNow component uses Jackson Databind to translate request/response to/from Json and you can customize how it is done by providing a custom ObjectMapper

 

Headers

NameTypeDescription
CamelServiceNowResourceStringThe resource to access TABLE, AGGREGATE, IMPORT
CamelServiceNowTableString

The table to access

CamelServiceNowActionString

The action to perform RETRIEVE, CREATE, MODIFY, DELETE, UPDATE

CamelServiceNowModelClassThe data model
CamelServiceNowSysIdStringServiceNow sysy_id
CamelServiceNowQueryStringAn encoded query
CamelServiceNowDisplayValueStringReturn the display value (true), actual value (false), or both (all) for reference fields (default: false)
CamelServiceNowInputDisplayValueBooleanTrue to set raw value of input fields
CamelServiceNowExcludeReferenceLinkBooleanTrue to exclude Table API links for reference fields
CamelServiceNowFieldsStringComma-separated field names to return in the response
CamelServiceNowMinFieldsStringA comma-separated list of fields for which to calculate the minimum value
CamelServiceNowMaxFieldsStringA comma-separated list of fields for which to calculate the maximum value
CamelServiceNowSumFieldsStringA comma-separated list of fields for which to calculate the sum of the values
CamelServiceNowLimitIntegerLimit to be applied on pagination
CamelServiceNowViewStringUI view to determine fields returned in the response.
CamelServiceNowSuppressAutoSysFieldBooleanTrue to suppress auto generation of system fields
CamelServiceNowAvgFieldsStringA comma-separated list of fields for which to calculate the average value
CamelServiceNowCountBooleanA boolean flag. You can set this parameter to true for the number of records returned by the query
CamelServiceGroupByStringThe fields to group the returned data by
CamelServiceOrderByStringA list of values to order grouped results by
CamelServiceHavingStringAn additional query allowing you to filter the data based on an aggregate operation

 

Usage examples:

 

context.addRoutes(new RouteBuilder() {
    public void configure() {
       from("direct:servicenow")
           .to("servicenow:{{env:SERVICENOW_INSTANCE}}"
               + "?userName={{env:SERVICENOW_USERNAME}}"
               + "&password={{env:SERVICENOW_PASSWORD}}"
               + "&oauthClientId={{env:SERVICENOW_OAUTH2_CLIENT_ID}}"
               + "&oauthClientSecret={{env:SERVICENOW_OAUTH2_CLIENT_SECRET}}"
               + "&model.incident=org.apache.camel.component.servicenow.model.Incident")
           .to("mock:servicenow");
    }
}); Map<String, Object> headers = new HashMap<>();headers.put(ServiceNowConstants.RESOURCE, "table");
headers.put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_RETRIEVE);
headers.put(ServiceNowConstants.SYSPARM_LIMIT, "10");
headers.put(ServiceNowConstants.TABLE, "incident");template.sendBodyAndHeaders("direct:servicenow", null, headers);
  • No labels