Click HERE to see how Saviynt Intelligence is transforming the industry. |
07/24/2024 05:24 AM
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
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
Solved! Go to Solution.
07/24/2024 05:32 AM
@Naveen_Talanos FYI ,Connection name should same in every JSON. please correct it and try
"authentications": {
"acctAuth": {
"connection": "userAuth",
07/24/2024 05:58 AM
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
07/24/2024 09:06 AM
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.‼️‼️⚠️
07/24/2024 09:23 AM
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'
Regards
Naveen
07/24/2024 09:26 AM
Are you able toc create ticket from postman ? If yes share screenshot. as per above screenshot scope is useraccount
07/24/2024 09:35 AM - edited 07/24/2024 09:35 AM
ServiceNow team has created a function and exposed as REST. I do get a ticket number back.
Should the scope be different to useraccount?
Regards
Naveen
07/24/2024 10:40 AM
Share curl
07/24/2024 10:50 AM
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"
}'
07/24/2024 10:51 AM
07/24/2024 11:06 AM
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?
07/24/2024 07:25 PM
Does token is static or dynamic ?
07/24/2024 07:33 PM
Refresh token is same every time I generate it.
07/24/2024 07:37 PM
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" }
}
}
07/24/2024 08:49 PM
07/24/2024 09:42 PM
@rushikeshvartak I am able to create ticket from Saviynt now.
I had extra "/" in my URL in CreateTicketJSON that was giving "
Regards,
Naveen
07/24/2024 10:06 PM
Great you can accept solution to help others
07/24/2024 09:39 AM
@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>" },
07/24/2024 10:40 AM
Hi @SumathiSomala
Still the same error
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
07/24/2024 05:56 AM
-- 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
]
}
}
]
}