PARTNERS - Please join us for our upcoming webinar:
Leveraging Intelligent Recommendations for Operational Transformation.
AMS Partners click HERE | EMEA/APJ Partners click HERE

Rest Connector - Connection JSON Error

harish14
New Contributor
New Contributor

Hi Team,

I am working on a REST connector (Authentication type as OAUTH). when we try to do a test connection by using below connectionJSON it's throwing below errors.

2022-08-08T18:13:46.397366975Z stdout F 2022-08-08 18:13:46,397 [elastic-apm-server-reporter] ERROR co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Failed to handle event of type JSON_WRITER with this error: Connection refused (Connection refused)

:52:49.20769396Z stdout F org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'groovy.util.ConfigObject@296fc94b' with class 'groovy.util.ConfigObject' to class 'java.util.List' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.util.List(groovy.util.ConfigObject)

Connection JSON:

{
"authentications":{
"userAuth":{
"authType":"oauth2",
"url":"URL",
"httpMethod":"POST",
"httpParams":{
"Key":"ABCXYZ",
"Id":"12345",
"Secret":"ABCXYZ",
"Resource":"Verity Connect",
"Instance":""
},
"httpHeaders":{
"Content-Type":"application/json"
},
"httpContentType":"application/x-www-form-urlencoded",
"authError":[
"InvalidAuthenticationToken",
"AuthenticationFailed"
],
"retryFailureStatuscode":[
401,
403
],
"errorPath":"",
"tokenResponsePath":"Value.value",
"tokenType":"Bearer",
"accessToken":"xyx-123-abc-456"
}
}
}

Postman Request:

    "Key" : "XYZ-1234-abcd",
    "Id""1234",
    "Secret""somexyz",
    "Resource""Verity Connect",
    "Instance" : ""
}

Response:

{
    "Code"1000,
    "Description""",
    "Timestamp""2022-08-08",
    "Value": {
        "Expiration""2022-08-08",
        "Id""1234",
        "Resource""Verity Connect",
        "Value""Access Token Generated Value"
    }
}
 
Expectation -   Connection has to be established based OAUTH Access token. 
 
Any assistance?
5 REPLIES 5

rushikeshvartak
All-Star
All-Star

{
"authentications":{
"userAuth":{
"authType":"oauth2",
"url":"URL",
"httpMethod":"POST",
"httpParams":{
"Key":"ABCXYZ",
"Id":"12345",
"Secret":"ABCXYZ",
"Resource":"Verity Connect",
"Instance":""
},
"httpHeaders":{
"Content-Type":"application/json"
},
"httpContentType":"application/x-www-form-urlencoded",
"authError":[
"InvalidAuthenticationToken",
"AuthenticationFailed"
],
"retryFailureStatuscode":[
401,
403
],
"errorPath":"Value.value",
"tokenResponsePath":"access_token",
"tokenType":"Bearer",
"accessToken":"xyx-123-abc-456"
}
}
}


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

Hello,

Thanks for the reply!

Still facing the below error i.e;

2022-08-09T11:47:05.651273632Z stdout F 2022-08-09 11:47:05,651 [elastic-apm-server-reporter] ERROR co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Failed to handle event of type JSON_WRITER with this error: Connection refused (Connection refused)

 

Can you confirm if above connection working from Postman &share screenshot for same


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

connectionJSON:

{
"authentications":{
"userAuth":{
"authType":"oauth2",
"url":"URL",
"httpMethod":"POST",
"httpParams":"{\"Key\":\"123456789\",\"Id\":\"12345\",\"Secret\":\"xyz123abc456\",\"Resource\":\"Verity Connect\"}",
"httpHeaders":{
"Content-Type":"application/json",
"Accept": "application/json"
},
"httpContentType":"application/json",
"successResponses":{},
"unsuccessResponses":{},
"errorPath":"Code",
"tokenResponsePath":"Value.Value",
"accessToken": "",
"tokenType": "OAuth",
"authHeaderName": "Access-Token"

}
}
}

==============
ImportUserJSON:

{
"connection":"userAuth",
"url":"URL",
"httpMethod":"POST",
"httpHeaders":{
"Access-Token":"{\"Token\": \"${access_token}\"}",
"Accept":"application/json"
},
"httpParams":"{\"Id\":\"1234\"}",
"userResponsePath":"Value.Result",
"colsToPropsMap":{
"username":"id~#~char",
"systemUserName":"id~#~char",
"firstname":"FirstName~#~char",
"lastname":"LastName~#~char"
}
}

Postman Request:

Inside Body

    "Key" : "123456789",
    "Id""12345",
    "Secret""xyz123abc456",
    "Resource""Verity Connect",
    "Instance" : ""
}
Response:
{
    "Code"1000,
    "Description""",
    "Timestamp""2022-08-09T18:30:01.5762243Z",
    "Value": {
        "Expiration""2022-08-09T18:40:01.5362552Z",
        "Id""12345",
        "Resource""Verity Connect",
        "Value""Access Token Generated"
    }
}
===========
When we run the user import job it's sending null access token, and getting below error
Error Message:
2022-08-09T19:12:59.545524241Z stdout F 2022-08-09 19:12:59,545 [http-nio-8080-exec-15] DEBUG domain.FlatViewJobcontrolController - After fetching jobEnddate and SavResponse from EcmImportJob first element from qrtzTriggerDataList : [job_name:UserImportJob, job_group:DATA, trigger_name:Test_REST, trigger_group:GRAILS_JOBS, next_fire_time:4070945700000, CRON_EXPRESSION:0 15 10 * * ? 2099, TRIGGER_STATE:WAITING, SAVRESPONSE:Error - to Import Data correctly: Getting null access_token for connection-userAuth, prev_fire_time:2022-08-09 18:36:04.0]
 
 
2022-08-09T19:12:39.854133118Z stdout F 2022-08-09 19:12:39,854 [elastic-apm-server-reporter] ERROR co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Failed to handle event of type JSON_WRITER with this error: Connection refused (Connection refused)
 
2022-08-09T19:11:29.374540962Z stdout F 2022-08-09 19:11:29,374 [http-nio-8080-exec-13] DEBUG println.PrintlnToLogger - Println :: ERROR UNAUTH FOR URLhttps://client-dev.saviyntcloud.com/ECM/flatViewJobcontrol/flatViewJobList
 
2022-08-09T19:11:23.715877859Z stdout F 2022-08-09 19:11:23,715 [http-nio-8080-exec-24] ERROR error.ErrorController - Exception
 
 
 
 

ImportUserJSON is not getting access_token from connectionJson

can you try below

ConnectionJson 

"retryFailureStatusCode": [],
"maxRefreshTryCount": 5,
"accessToken": "Bearer abcd"

 


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