Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

REST ConnectionJSON not transforming the request properly

mmomin-xalient
New Contributor III
New Contributor III

Hello,

I am setting up a new REST connector and test connection is failing with internal server error. Seem the server is not like the request payload and throwing the error. I have tested the endpoint via postman, and it is working as expected. 

I even tried hardcoding the access token in the testConnectionParams but even that is not working. Please help with this. 

Following is the ConnectionJSON I am using and the postman curl request.

ConnectionJSON:

{
"authentications": {
"acctAuth": {
"authType": "oauth2",
"httpHeaders": {
"Accept": "application/json"
},
"url": "http://xxxxxx:8080/saviynt-dev/api/UserManagement/GetAccessToken",
"httpMethod": "GET",
"httpContentType": "application/json",
"expiryError": "ExpiredAuthenticationToken",
"authError": [
"InvalidAuthenticationToken",
"AuthenticationFailed",
"SESSION_NOT_VALID",
"AuthenticationFailed",
"HTTP Error 401 - Unauthorized: Access is denied"
],
"errorPath": "errorCode",
"maxRefreshTryCount": 2,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"accessToken": "Bearer ABCD",
"httpParams": "{\"username\": \"domain\\\\\\\\Svc-account\",\"password\": \"xxxxxxxx\"}",
"retryFailureStatusCode": [
401
],
"testConnectionParams": {
"http": {
"url": "http://xxxxxx:8080/saviynt-dev/api/UserManagement/GetUser",
"httpMethod": "GET",
"httpHeaders": {
"Authorization": "${access_token}",
"Content-Type": "application/x-www-form-urlencoded"
},
"httpContentType": "application/x-www-form-urlencoded",
"httpParams": "{\"LoginName\": \"domain\\\\\\\\Svc-account\"}"
},
"successResponse": [
"domain\\Svc-account"
],
"successResponsePath": "value[0][0].domainname"
}
}
}
}

CURL Command:

curl --location --request GET 'http://xxxxxxxxx:8080/saviynt-dev/api/UserManagement/GetUser' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjQ0MDF2djIzVEYyV3pITlo0WTVWREctem0wSSJ9.eyJhdWQiOiJodHRwczovL2NybWRldi5icmlnaH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'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'LoginName=domain\Svc-account'

 

23 REPLIES 23

rushikeshvartak
All-Star
All-Star

Could you kindly provide a detailed snapshot of the information extracted from the logs, encompassing errors and other pertinent functionality details encountered during the execution of this process? Your assistance in furnishing this information would greatly aid in the analysis and resolution of any issues .



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


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Following is the error I am seeing in the logs. 

2024-05-20T17:44:51-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-DEBUG-Got Webservice API Response: [headers:[Cache-Control: no-cache, Pragma: no-cache, Content-Type: application/json; charset=utf-8, Expires: -1, Server: Microsoft-IIS/10.0, X-AspNet-Version: 4.0.30319, X-Powered-By: ASP.NET, Date: Mon, 20 May 2024 21:44:51 GMT, Content-Length: 36], responseText:{"Message":"An error has occurred."}, cookies:[], statusCode:500]
 
2024-05-20T17:44:51-04:00-ecm-rest.RestUtilService-http-nio-8080-exec-4-czpd9-DEBUG-pullObjectsByRest - responseStatusCode ::500
 
2024-05-20T17:44:51-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-DEBUG-Entered getResponseHeaders method
 
2024-05-20T17:44:51-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-DEBUG-responseError : null
 
2024-05-20T17:44:51-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-DEBUG-isAuthError: false
 
2024-05-20T17:44:51-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-DEBUG-pullObjectsByRest - responseMap.size : 1
 
2024-05-20T17:44:51-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-DEBUG-pullObjectsByRest - objectList.size : 1
 
2024-05-20T17:44:51-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-DEBUG-responseTextMap of testConnectionRest: [Message:An error has occurred.]
 
2024-05-20T17:44:51-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-DEBUG-Inside validateErrorResponse
 
2024-05-20T17:44:51-04:00-ecm-validation.ValidationHelperService-http-nio-8080-exec-4-czpd9-DEBUG-Inside validateCommonErrorResponse
 
2024-05-20T17:44:51-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-ERROR-Error while saving the Connection:
 
2024-05-20T17:44:52-04:00-ecm--null-czpd9--java.lang.Exception: Target Response status Code: 500, Target Error Message: [{"Message":"An error has occurred."}] at com.saviynt.provisoning.rest.RestProvisioningService.validateErrorResponse(RestProvisioningService.groovy:11146) at com.saviynt.provisoning.rest.RestProvisioningService.testConnectionRest(RestProvisioningService.groovy:11111) at com.saviynt.ecm.integration.ExternalConnectionCallService.testExternalConnection(ExternalConnectionCallService.groovy:1012) at com.saviynt.ecm.utility.domain.EcmConfigController$_closure21.doCall(EcmConfigController.groovy:772) at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53) at com.saviynt.webservice.SaviyntRestAuthenticationFilter.doFilter(SaviyntRestAuthenticationFilter.groovy:158) at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:62) at grails.plugin.springsecurity.web.SecurityRequestHolderFilter.doFilter(SecurityRequestHolderFilter.java:59) at com.mrhaki.grails.plugin.xframeoptions.web.XFrameOptionsFilter.doFilterInternal(XFrameOptionsFilter.java:69) at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:82) at java.lang.Thread.run(Thread.java:750)
 
2024-05-20T17:44:51-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-DEBUG-response of testConnectionRest: false
 
2024-05-20T17:44:51-04:00-ecm-integration.ExternalConnectionCallService-http-nio-8080-exec-4-czpd9-DEBUG-EXIT invokeExternalMethod
 
2024-05-20T17:44:45-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-DEBUG-Inside pullObjectsByRest
 
2024-05-20T17:44:45-04:00-ecm-rest.RestUtilService-http-nio-8080-exec-4-czpd9-DEBUG-Got showLogs = true
 
2024-05-20T17:44:45-04:00-ecm-rest.RestProvisioningService-http-nio-8080-exec-4-czpd9-DEBUG-Calling Webservice Url - http://xx.xxx.xxx.xx:8080/saviynt-dev/api/UserManagement/GetUser with httpParams - [LoginName:domain\Svc-account]

[This post has been edited by a Moderator to remove sensitive information.]

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 you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

mmomin-xalient
New Contributor III
New Contributor III

Hello, CURL command is in the main description but here it is again. 

CURL Command:

curl --location --request GET 'http://xxxxxxxxx:8080/saviynt-dev/api/UserManagement/GetUser' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjQ0MDF2djIzVEYyV3pITlo0WTVWREctem0wSSJ9.eyJhdWQiOiJodHRwczovL2NybWRldi5icmlnaHRob3Jpem9ucy5jb20vYXBpL2RhdGEvdjkuMS8iLCJpc3MiOiJodHRwOi8vYmhjbXBkdHNhZGYuYnJpZ2h0aG9yaXpvbnMuY29tL2FkZnMvc2VydmljZXMvdHJ1c3QiLCJpYXQiOjE3MTYyMjkwNjMsImV4cCI6MTcxNjIzMjY2MywicHJpbWFyeXNpZCI6IlMtMS01LTIxLTE0MDkwODIyMzMtMTIyOTI3MjgyMS0xODAxNjc0NTMxLTM5NTkwMyIsInVwbiI6WyJTdmMtU2F2aUQtQ1JNQGJyaWdodGhvcml6b25zLmNvbSIsInN2Yy1zYXZpZC1jcm1AYnJpZ2h0aG9yaXpvbnMuY29tIl0sInVuaXF1ZV9uYW1lIjoiQlJJR0hUSE9SSVpPTlNcXFN2Yy1TYXZpRC1DUk0iLCJhcHB0eXBlIjoiQ29uZmlkZW50aWFsIiwiYXBwaWQiOiI3YzI3MTQ1NS1kYzc0LTQ0OTYtYWU2OS0wYzkxZjg4NjhlYWIiLCJhdXRobWV0aG9kIjoidXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmFjOmNsYXNzZXM6UGFzc3dvcmRQcm90ZWN0ZWRUcmFuc3BvcnQiLCJhdXRoX3RpbWUiOiIyMDI0LTA1LTIwVDE4OjE3OjQzLjQ5OVoiLCJ2ZXIiOiIxLjAifQ.tucyrEr1b4TjiKVcF10fXv_pa5WvaMHkOAa1XaI8v-lvB0lNgMvygGEGRLTQnxF4rxajpoQMFwbVaWroN0dA5GGHAKHJJB2H3XD26kEQWHoF2PfZWAMSUshv3vl7XoXVpEhhT4FLxQ2lfzFx4XRErtn7vU6DuX3BkLGkw71zEW2swnHW1qx9bBqcTidnjpP5AYa4J120tA3Iu-92Qo4ZtoMk_cXzJgzaI2imyxTa7qOzSPIcVjMPXOt7a6J3kUDTG3PvG2LDaWKKeT0MzHvjNKH1_p-UUZaOhdA8h8uF_oT7FpWYAn-eKy_2ZKN6NkpnrtcippKH921dQkSXqS1R3Q' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'LoginName=domain\Svc-account'

mmominxalient_0-1716292855230.png

mmominxalient_1-1716292956644.png

mmominxalient_2-1716293090314.png

Share get token postman screenshot 


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Here you go,

mmominxalient_0-1716296442951.png

mmominxalient_1-1716296505640.png

 

 

Does it works with POST method also send curl command


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

mmomin-xalient
New Contributor III
New Contributor III

Nope, getting following error.

 

{
    "Message": "The requested resource does not support http method 'POST'."
}

Try http method GETWITHBODY if does not work need curl for get token


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Can you share example?

{
"authentications": {
"acctAuth": {
"authType": "oauth2",
"httpHeaders": {
"Accept": "application/json"
},
"url": "http://xxxxxx:8080/saviynt-dev/api/UserManagement/GetAccessToken",
"httpMethod": "GETWITHBODY",
"httpContentType": "application/json",
"expiryError": "ExpiredAuthenticationToken",
"authError": [
"InvalidAuthenticationToken",
"AuthenticationFailed",
"SESSION_NOT_VALID",
"AuthenticationFailed",
"HTTP Error 401 - Unauthorized: Access is denied"
],
"errorPath": "errorCode",
"maxRefreshTryCount": 2,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"accessToken": "Bearer ABCD",
"httpParams": "{\"username\": \"domain\\\\\\\\Svc-account\",\"password\": \"xxxxxxxx\"}",
"retryFailureStatusCode": [
401
],
"testConnectionParams": {
"http": {
"url": "http://xxxxxx:8080/saviynt-dev/api/UserManagement/GetUser",
"httpMethod": "GET",
"httpHeaders": {
"Authorization": "${access_token}",
"Content-Type": "application/x-www-form-urlencoded"
},
"httpContentType": "application/x-www-form-urlencoded",
"httpParams": "{\"LoginName\": \"domain\\\\\\\\Svc-account\"}"
},
"successResponse": [
"domain\\Svc-account"
],
"successResponsePath": "value[0][0].domainname"
}
}
}
}


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Thank you!! Now the test connection works if i pass the valid token but if the token is not valid, it makes the getAccesstoken call and that fails with following error. 

 

2024-05-21T10:04:34-04:00-ecm-rest.RestUtilService-http-nio-8080-exec-12-9brx6-DEBUG-Calling http://xxxxxxxxxxxxxxxxxxxxxxxxxxx:8080/saviynt-dev/api/UserManagement/GetAccessToken
2024-05-21T10:04:34-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-calling executeRequestWithTimeoutConfig for api...
2024-05-21T10:04:34-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-calling api...
2024-05-21T10:04:34-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-before calling executeRequestWithHeaders for api...
2024-05-21T10:04:34-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-isFipsEnabled = false
2024-05-21T10:04:34-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-getHttpClient - proxyParams : null
2024-05-21T10:04:34-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-getHttpClient - sslSocketFactory : null
2024-05-21T10:04:34-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-setting connection timeout to 10 seconds and request timeout to 60 seconds
2024-05-21T10:04:34-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-getHttpClient - HttpClientBuilder.create().build() called.
2024-05-21T10:04:34-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-Exception in setHttpBody:
2024-05-21T10:04:35-04:00-ecm--null-9brx6--groovy.lang.MissingMethodException: No signature of method: java.lang.String.keySet() is applicable for argument types: () values: []
2024-05-21T10:04:35-04:00-ecm--null-9brx6--Possible solutions: toSet(), toSet(), next(), next(), getAt(java.lang.String), getAt(groovy.lang.EmptyRange)
2024-05-21T10:04:35-04:00-ecm--null-9brx6--at com.saviynt.ecm.services.HttpClientUtilityService.setHttpBody(HttpClientUtilityService.groovy:1358)
2024-05-21T10:04:35-04:00-ecm--null-9brx6--at com.saviynt.ecm.services.HttpClientUtilityService.executeGetBodyRequestWithHeaders(HttpClientUtilityService.groovy:1426)
2024-05-21T10:04:35-04:00-ecm--null-9brx6--at com.saviynt.ecm.services.HttpClientUtilityService.executeRequestWithHeaders(HttpClientUtilityService.groovy:671)
2024-05-21T10:04:35-04:00-ecm--null-9brx6--at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:82)
2024-05-21T10:04:35-04:00-ecm--null-9brx6--at java.lang.Thread.run(Thread.java:750)
2024-05-21T10:04:35-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-called executeGetBodyRequestWithHeaders for api...
2024-05-21T10:04:35-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-after calling executeRequestWithHeaders for api...
2024-05-21T10:04:35-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-called api...
2024-05-21T10:04:35-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-timeout validated for api...
2024-05-21T10:04:35-04:00-ecm-services.HttpClientUtilityService-http-nio-8080-exec-12-9brx6-DEBUG-got response for api...
2024-05-21T10:04:35-04:00-ecm-rest.RestUtilService-http-nio-8080-exec-12-9brx6-DEBUG-fetching result from response.responseText
2024-05-21T10:04:35-04:00-ecm-rest.RestUtilService-http-nio-8080-exec-12-9brx6-DEBUG-responseToken is null or empty

Here is the ConnectionJson

{
"authentications": {
"acctAuth": {
"authType": "oauth2",
"httpHeaders": {
"Content-Type": "application/x-www-form-urlencoded"
},
"url": "http://xxxxxxx:8080/saviynt-dev/api/UserManagement/GetAccessToken",
"httpMethod": "GETWITHBODY",
"httpContentType": "application/x-www-form-urlencoded",
"expiryError": "ExpiredAuthenticationToken",
"authError": [
"InvalidAuthenticationToken",
"AuthenticationFailed",
"SESSION_NOT_VALID",
"AuthenticationFailed",
"invalid_grant"
],
"errorPath": "error",
"maxRefreshTryCount": 2,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"accessToken": "Bearer ABCD",
"httpParams": "{\"username\": \"domain\\\\\\\\Svc-account\",\"password\": \"xxxxxxxxxxxxxxxxx\"}",
"retryFailureStatusCode": [
400
],
"testConnectionParams": {
"http": {
"url": "http://xxxxxxxxxxxxxxxxxxxx:8080/saviynt-dev/api/UserManagement/GetUser",
"httpMethod": "GETWITHBODY",
"httpHeaders": {
"Authorization": "${access_token}",
"Content-Type": "application/x-www-form-urlencoded"
},
"httpContentType": "application/x-www-form-urlencoded",
"httpParams": "{\"LoginName\": \"domian\\\\\\\\Svc-account\"}"
},
"successResponse": [
"domain\\Svc-account"
],
"successResponsePath": "domainname"
}
}
}
}

NM
Valued Contributor
Valued Contributor

Hi @mmomin-xalient , if we hit token URL without body does it give any result?? Maybe check once from postaman

mmomin-xalient
New Contributor III
New Contributor III

I am getting internal server error when I hit the URL without body. 

Since connection is working as per original ask . Please close this thread and create new thread for import issue

👍Please click the 'Accept As Solution' button on the reply (or replies) that best answered your original question.


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

NM
Valued Contributor
Valued Contributor

@mmomin-xalient , okay.. try now from saviynt and share the full logs..

*Mask the confidential value.

mmomin-xalient
New Contributor III
New Contributor III

Please see attached logs. 

mmomin-xalient
New Contributor III
New Contributor III

Just a note though, regardless of me passing the body as httpParams or not, the error is same as in the logs attached. 

NM
Valued Contributor
Valued Contributor

Can you share postman "token" call SS as well?

mmomin-xalient
New Contributor III
New Contributor III

See below.

With Body:

mmominxalient_0-1716304663061.png

 

Without Body:

mmominxalient_1-1716304732047.png

 

NM
Valued Contributor
Valued Contributor

Hi @mmomin-xalient , is the issue resolved, you were able to map access token to subsequent call?

mmomin-xalient
New Contributor III
New Contributor III

First issue got resolved but since then I been having issues with what I shared with you, If you can assist pls.