Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

ServiceNow Rest Connection - Ticket Creation

Naveen_Talanos
Regular Contributor II
Regular Contributor II

Hi Experts,

Please help.

I am trying to configure ServiceNow REST connection. I want to use ServiceNow to create tickets.

But getting below in logs

Naveen_Talanos_0-1721822482000.png

Below is my connection JSON:

 

{
    "authentications": {
        "acctAuth": {
            "authType": "oauth2",
            "httpHeaders": {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            "authError": [
                "access_denied",
                " 401",
                " server_error"
            ],
            "url": "https://client.service-now.com/oauth_token.do",
            "httpMethod": "POST",
            "httpContentType": "application/x-www-form-urlencoded",
            "errorPath": "error_description",
            "maxRefreshTryCount": 5,
            "tokenResponsePath": "access_token",
            "tokenType": "Bearer",
            "authHeaderName": "Authorization",
            "accessToken": "Bearer _nsaXXXXXXXXXXXXX-cchw",
            "httpParams": {
                "password": "0KXXXXXXXXXXXXXX45r",
                "grant_type": "password",
                "client_secret": "8XXXXXXXU",
                "client_id": "ad4YYYYYYYYYYYY90YY",
                "username": "saviynt_user"
            },
            "retryFailureStatusCode": [
                401
            ]
        }
    }
}

 

 

Below is my CreateTIcket JSON

 

 

 

{
  "call": [
    {
      "name": "call1",
      "connection": "userAuth",
      "url": "https://client.service-now.com/api/quich/saviynt",
      "httpMethod": "POST",
      "httpParams": "{\"first_name\":\"Naveen\",\"last_name\":\"Sharma\",\"email\":\"test.service@client.com\",\"application\":\"ABC\",\"action\":\"remove\"}",
      "httpHeaders": {
        "Authorization": "${access_token}"},
      "httpContentType": "application/json",
      "ticketidPath": "result.request_item",
      "ticketStatusPath": "result.status",
      "ticketStatusValue": [
        "success",
        "OPEN",
        "open"      ],
      "successResponses": {
        "statusCode": [
          200,
          201
        ]
      }
    }
  ]
}

 

 

Please note that it works fine in Postman

Regards

Naveen

@rushikeshvartak #ServiceNow 

 

19 REPLIES 19

SumathiSomala
All-Star
All-Star

@Naveen_Talanos FYI ,Connection name should same in every JSON. please correct it and try

"authentications": {
"acctAuth": {

 

"connection": "userAuth",

 

 

Regards,
Sumathi Somala

If this reply answered your question, please Accept As Solution and give Kudos.

Thanks @SumathiSomala for your reply.

That was my typo while creating this thread. In the system connection is "acctAuth"

The error is with connection mentioned as "acctAuth"

Regards

Naveen

Please share postman screenshot and curl command [Refer https://codingnconcepts.com/postman/how-to-generate-curl-command-from-postman/ ]



⚠️‼️‼️Do not upload any attachments that contain sensitive information, such as IP Addresses, URLs, Company/Employee Names, Email Addresses, etc.‼️‼️⚠️

 

 


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Hi @rushikeshvartak 
Thanks for your reply

curl --location 'https://clientdev.service-now.com/oauth_token.do' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: BIGipServerpool_clientdev=de78XXXXXXXXXXXXXX1d0b28; JSESSIONID=06E0D61XXXXXXX6AECF017; glide_node_id_for_js=f45axxxxxxxxxxxxxxc0a98e8363ac61dad92a37df6e57065c4; glide_user_route=glide.a587880bxxxxxxxxx036aa31d66313' \
--data-urlencode 'username=XXXXX_rest' \
--data-urlencode 'password=XXXXXXXXXXXXX' \
--data-urlencode 'client_id=XXXXXX' \
--data-urlencode 'client_secret=XXXXXX' \
--data-urlencode 'grant_type=password'

 

Naveen_Talanos_0-1721838207353.png

Regards

Naveen

Are you able toc create ticket from postman ? If yes share screenshot. as per above screenshot scope is useraccount


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Hi @rushikeshvartak 

ServiceNow team has created a function and exposed as REST. I do get a ticket number back.
Should the scope be different to useraccount?

Naveen_Talanos_0-1721838802453.png

Regards

Naveen

Share curl


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

curl --location 'https://client.service-now.com/api/quich/saviynt' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer mXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxgw_kPw' \
--header 'Cookie: BIGipServerpool_quilterdev=de7855XXXXXXXXXXX0b28; JSESSIONID=A3EF7EXXXXXXXXX0049B79; glide_node_id_for_js=f45axxxxxxxxxxxxxxxxxxxxxxxxxxxx1dad92a37df6e57065c4; glide_session_store=F36XXXXXXXXXXXXXXXXXXXFD9AAEEFDC0D; glide_user_route=glide.a587880bb211111111111d66313' \
--data-raw '{
"first_name": "Naveen",
"last_name": "LastN",
"email":"c.in@client.com",
"application": "ABC",
"action_date": "18/07/2024",
"action": "remove"
}'

Common Reasons

  1. Incorrect Endpoint: The URI might be incorrect or malformed.
  2. Missing Resource: The resource you are trying to access does not exist.
  3. Permissions Issue: The user making the request might not have the necessary permissions.
  4. Incorrect Instance: Ensure you are making the request to the correct ServiceNow instance.
  5. Endpoint Configuration: There could be an issue with the way the endpoint is configured.

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Thanks for reply @rushikeshvartak 
But do you think any of these will be a reason when I am getting response from Postman?

Could you guide on below?
1. Which password is this looking for? 
PARENT.ADMIN is missing :: skipping token generation
PARENT.PWD is missing :: skipping token generation

2. In access token in Connection JSON, do I put access_token or refresh_token? And should it have "Bearer" before the token?

 "accessToken": "Bearer _nsaXXXXXXguNNxKaiD-cchw",
 
Regards
Naveen

 

Does token is static or dynamic  ?


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Refresh token is same every time I generate it.

Try

{
  "authentications": {
    "userAuth": {
      "authType": "oauth2",
      "url": "https://<domain name>/oauth_token.do",
      "httpParams": {
        "password": "<password>",
        "grant_type": "password",
        "scope": "useraccount",
        "client_id": "<client id>",
        "client_secret": "<client secret>",
        "username": "<username>"      },
      "httpHeaders": {
        "Content-Type": "application/x-www-form-urlencoded"      },
      "authError": [
        "InvalidAuthenticationToken"      ],
      "httpMethod": "POST",
      "httpContentType": "application/x-www-form-urlencoded",
      "errorPath": "error.code",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "access_token",
      "tokenType": "Bearer",
      "retryFailureStatusCode": [
        401
      ],
      "accessToken": "Bearer token"    }
  }
}

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Hi @rushikeshvartak 

Still the same

Naveen_Talanos_0-1721879325198.png

Regards

Naveen

@rushikeshvartak I am able to create ticket from Saviynt now.

I had extra "/" in my URL in CreateTicketJSON that was giving "

Requested URI does not represent any resource" error. I was able to replicate the issue in Postman.
 
Removing the extra "/" fixed the issue.
Really appreciate your help.

Naveen_Talanos_0-1721882356935.png

Regards,

Naveen

 

 

Great you can accept solution to help others


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

@Naveen_Talanos Update the scope in httpParams

"httpParams": {

        "password": "<password>",

        "grant_type": "password",

        "scope": "useraccount",

        "client_id": "<client id>",

        "client_secret": "<client secret>",

        "username": "<username>"      },

Regards,
Sumathi Somala

If this reply answered your question, please Accept As Solution and give Kudos.

Hi @SumathiSomala 

Still the same error

Naveen_Talanos_0-1721842702891.png

Updated JSON

{
    "authentications": {
        "acctAuth": {
            "authType": "oauth2",
            "httpHeaders": {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            "authError": [
                "access_denied",
                " 401",
                " server_error"
            ],
            "url": "https://client.service-now.com/oauth_token.do",
            "httpMethod": "POST",
            "httpContentType": "application/x-www-form-urlencoded",
            "errorPath": "error_description",
            "maxRefreshTryCount": 5,
            "tokenResponsePath": "access_token",
            "tokenType": "Bearer",
            "authHeaderName": "Authorization",
            "accessToken": "Bearer _XXXXXXXXXXXXXXXXXguNNxKaiD-XXXw",
            "httpParams": {
                "password": "0XXXXXXXXXXXXXXXXXXXxx",
                "grant_type": "password",
                "client_secret": "XXXXXXXXXX",
                "client_id": "aXXXXXXXXXXXXXXb0",
                "username": "XXXX_rest",
                "scope": "useraccount"
            },
            "retryFailureStatusCode": [
                401
            ]
        }
    }
}

Regards

Naveen

Naveen_Talanos
Regular Contributor II
Regular Contributor II

-- Correction --
Below is my CreateTIcket JSON (updated connection)

{
  "call": [
    {
      "name": "call1",
      "connection": "acctAuth",
      "url": "https://client.service-now.com/api/quich/saviynt",
      "httpMethod": "POST",
      "httpParams": "{\"first_name\":\"Naveen\",\"last_name\":\"Sharma\",\"email\":\"test.service@client.com\",\"application\":\"ABC\",\"action\":\"remove\"}",
      "httpHeaders": {
        "Authorization": "${access_token}"},
      "httpContentType": "application/json",
      "ticketidPath": "result.request_item",
      "ticketStatusPath": "result.status",
      "ticketStatusValue": [
        "success",
        "OPEN",
        "open"      ],
      "successResponses": {
        "statusCode": [
          200,
          201
        ]
      }
    }
  ]
}