We are delighted to share our new EIC Delivery Methodology for efficiently managing Saviynt Implementations and delivering quick time to value. CLICK HERE.

REST Connector - Connection JSON Issue

suryavav
New Contributor III
New Contributor III

We have a requirement to integrate the MasterControl application with Saviynt, which is REST API based. One point to notice is that the application's API supports passing the parameter in the body of the request. Therefore, we constructed our connection JSON and passed the parameters in the HTTP Param variable. Please refer to the JSON below, which we are using.

 

 
  "authentications": { 
    "acctAuth": { 
      "authType": "oauth2", 
      "url": "https://***********", 
      "httpMethod": "GET", 
      "httpParams": { 
        "arguments":{ 
        "apiKey":"********************************************", 
        "logoutCurrentWebConnection":false 
    }, 
    "methodName":"connectWithApiKey", 
    "serviceName":"ConnectionService" 
}, 
      "httpHeaders": { 
        "Content-Type": "application/json" 
      }, 
      "authError": [ 
        "InvalidAuthenticationToken" 
      ], 
      "httpContentType": "application/json", 
      "errorPath": "error.code", 
      "maxRefreshTryCount": 5, 
      "tokenResponsePath": "access_token", 
      "tokenType": "Bearer", 
      "retryFailureStatusCode": [ 
        401,
403
      ], 
      "accessToken": "Bearer <token>",
  "testConnectionParams": {
        "http": {
          "url": "https://****************************",
          "httpHeaders": {
            "Authorization": "${access_token}"
          },
          "httpContentType": "application/json",
          "httpMethod": "GET"
        },
        "successResponse": [],
        "successResponsePath": "",
        "errors": [
          "Couldn't authenticate you"
        ],
        "errorPath": "error"
      }
    } 
  } 

Upon making a test connection, we encountered the following error. Do you see any issues causing the error?

"responseTextMap of testConnectionRest: [error:[message:can't cast String [] to a value of type [struct], type:expression]]"

suryavav_0-1704296119525.png

 

22 REPLIES 22

sk
All-Star
All-Star

@suryavav : Are you sure that your authentication call is GET call instead of POST call? Can you please share the Postman screenshot of your authentication call?

 

   "acctAuth": { 
      "authType": "oauth2", 
      "url": "https://***********", 
      "httpMethod": "GET", 
      "httpParams": { 
        "arguments":{ 
        "apiKey":"********************************************", 
        "logoutCurrentWebConnection":false 
    }, 
    "methodName":"connectWithApiKey", 
    "serviceName":"ConnectionService" 
},

Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

suryavav
New Contributor III
New Contributor III

Authentication call is successful through postman and getting a result.

suryavav_0-1704297381191.png

 

@suryavav : Try below JSON

 

{
    "authentications": {
        "acctAuth": {
            "authType": "oauth2",
            "url": "https://***********",
            "httpMethod": "GET",
            "httpParams": {
                "arguments": {
                    "apiKey": "********************************************",
                    "logoutCurrentWebConnection": false
                },
                "methodName": "connectWithApiKey",
                "serviceName": "ConnectionService"
            },
            "httpHeaders": {
                "Content-Type": "text/plain"
            },
            "authError": [
                "InvalidAuthenticationToken"
            ],
            "httpContentType": "application/json",
            "errorPath": "error.code",
            "maxRefreshTryCount": 5,
            "tokenResponsePath": "access_token",
            "tokenType": "Bearer",
            "retryFailureStatusCode": [
                401,
                403
            ],
            "accessToken": "Bearer <token>",
            "testConnectionParams": {
                "http": {
                    "url": "https://****************************",
                    "httpHeaders": {
                        "Authorization": "${access_token}"
                    },
                    "httpContentType": "application/json",
                    "httpMethod": "GET"
                },
                "successResponse": [],
                "successResponsePath": "",
                "errors": [
                    "Couldn't authenticate you"
                ],
                "errorPath": "error"
            }
        }
    }
}

 


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

suryavav
New Contributor III
New Contributor III

I tried and still getting the same error. 

"2024-01-03T17:01:11.440+00:00","ecm","rest.RestProvisioningService","http-nio-8080-exec-177-rbvzc","DEBUG","responseTextMap of testConnectionRest: [error:[message:can't cast String [] to a value of type [struct], type:expression]]"

@suryavav : Sorry I missed to check this part, Does the response attribute result will hold the bearer token? 


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

suryavav
New Contributor III
New Contributor III

Yes, correct it holds the token. 

@suryavav : Then change 

 "tokenResponsePath": "access_token",

to and try

 "tokenResponsePath": "result",

 If it is still not working please share the postman screenshot for the call you making in testConnectionParams


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

{
  "authentications": {
    "acctAuth": {
      "authType": "oauth2",
      "url": "https://***********",
      "httpMethod": "GET",
      "httpParams": {
        "arguments": {
          "apiKey": "********************************************",
          "logoutCurrentWebConnection": false
        },
        "methodName": "connectWithApiKey",
        "serviceName": "ConnectionService"
      },
      "httpHeaders": {
        "Accept": "text/plain",
        "Content-Type": "application/json"
      },
      "httpContentType": "application/json",
      "authError": [
        "InvalidAuthenticationToken"
      ],
      "errorPath": "error.code",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "result",
      "tokenType": "Bearer",
      "retryFailureStatusCode": [
        401,
        403
      ],
      "accessToken": "Bearer <token>",
      "testConnectionParams": {
        "http": {
          "url": "https://****************************",
          "httpHeaders": {
            "Authorization": "${access_token}"
          },
          "httpContentType": "application/json",
          "httpMethod": "GET"
        },
        "successResponse": [
          200
        ],
        "successResponsePath": "result",
        "errors": [
          "Couldn't authenticate you"
        ],
        "errorPath": "error"
      }
    }
  }
}

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

suryavav
New Contributor III
New Contributor III

I tried using the recently shared JSON and still getting same error response. As instructed, I tried to call the parameters in "testConnectionParam" where I kept body blank and getting same error response from the target.

suryavav_0-1704356025608.png

Is the issue related to passing the parameters in 'httpparama'? I'm unsure if the syntax used to pass them in 'httpparamas' is correct. Do you see any issue because of this?

@suryavav : Were you able to make successful call using Postman for the call you are making in testConnectionParams? If so please share the screenshot of that 


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

suryavav
New Contributor III
New Contributor III

I added the 'testconnectionparams' attribute just to validate the connection JSON upon saving the connection. As we observed, Saviynt not log the authentication response and will not be printed in the logs.  Removing that from the connection JSON should also be fine.

Do you see any way to print if access token generated successfully or not upon test connection?

@suryavav : As you mentioned testConnectionParams block will help you to validate if token is generated successfully and working for any subsequent calls. So to make sure that in testConnectionParams block you have to use any GET call (instead of login /authentication call) for example may be a call you use to pull accounts/users/entitlements anything. If you used the same kind of calls please share the postman output of respective call and respective headers or body you passed for that call.


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

suryavav
New Contributor III
New Contributor III

Sorry for misunderstanding. Yes, through postman that call is successful and able to retrieve the accounts.

suryavav_0-1704386556708.png

 

  

@suryavav : Try below JSON

{
    "authentications": {
        "acctAuth": {
            "authType": "oauth2",
            "url": "https://***********",
            "httpMethod": "GET",
            "httpParams": {
                "arguments": {
                    "apiKey": "********************************************",
                    "logoutCurrentWebConnection": false
                },
                "methodName": "connectWithApiKey",
                "serviceName": "ConnectionService"
            },
            "httpHeaders": {
                "Content-Type": "text/plain"
            },
            "authError": [
                "InvalidAuthenticationToken"
            ],
            "httpContentType": "application/json",
            "errorPath": "error.code",
            "maxRefreshTryCount": 5,
            "tokenResponsePath": "result",
            "tokenType": "Bearer",
            "retryFailureStatusCode": [
                401,
                403
            ],
            "accessToken": "Bearer <token>",
            "testConnectionParams": {
                "http": {
                    "url": "https://****************************.cfm",
                    "httpParams": {
                        "arguments": {
                            "connectionID": "********************************************"
                        },
                        "methodName": "getAllUsers",
                        "serviceName": "UserService"
                    },
                    "httpHeaders": {
                        "Authorization": "${access_token}"
                    },
                    "httpContentType": "application/json",
                    "httpMethod": "GET"
                },
                "successResponses": {
                    "statusCode": [200]
                },
                "errors": [
                    "Couldn't authenticate you"
                ],
                "errorPath": "error.message"
            }
        }
    }
}

Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

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


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

Curl Command details. 

suryavav_2-1704440589476.png

 

 

@suryavav : I forgot to change method as GETWITHBODY in testConnectionParams. Please use below JSON

{
    "authentications": {
        "acctAuth": {
            "authType": "oauth2",
            "url": "https://***********",
            "httpMethod": "GET",
            "httpParams": {
                "arguments": {
                    "apiKey": "********************************************",
                    "logoutCurrentWebConnection": false
                },
                "methodName": "connectWithApiKey",
                "serviceName": "ConnectionService"
            },
            "httpHeaders": {
                "Content-Type": "text/plain"
            },
            "authError": [
                "InvalidAuthenticationToken"
            ],
            "httpContentType": "application/json",
            "errorPath": "error.code",
            "maxRefreshTryCount": 5,
            "tokenResponsePath": "result",
            "tokenType": "Bearer",
            "retryFailureStatusCode": [
                401,
                403
            ],
            "accessToken": "Bearer <token>",
            "testConnectionParams": {
                "http": {
                    "url": "https://****************************.cfm",
                    "httpParams": {
                        "arguments": {
                            "connectionID": "********************************************"
                        },
                        "methodName": "getAllUsers",
                        "serviceName": "UserService"
                    },
                    "httpHeaders": {
                        "Authorization": "${access_token}"
                    },
                    "httpContentType": "application/json",
                    "httpMethod": "GETWITHBODY"
                },
                "successResponses": {
                    "statusCode": [200]
                },
                "errors": [
                    "Couldn't authenticate you"
                ],
                "errorPath": "error.message"
            }
        }
    }
}

 


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

suryavav
New Contributor III
New Contributor III

I tried it through the recent provided JSON where kept "connectionID": "${access_token}"

The connection ID here is the generated token that we expect to generate through the connection call. but still getting same error. Also, we also noticed that in the log when calling the web service URL, it shows square brackets despite providing curly brackets in JSON. However, our expectation is to see curly brackets, as using square brackets didn't work through Postman, and the expected format is with curly brackets.

suryavav_0-1704438679572.png

I also wanted to bring to your attention that if we select 'No Auth' in the authorization through Postman, we will receive the expected response in both cases: when generating a connection ID (token) and when importing the account through utilizing the connectionID

KhalidAkhterIGA
New Contributor II
New Contributor II

Hi Surya,

In case you want to send Body params using a GET call, You need to use GETWITHBODY. Can you please try the below JSON and update.

{
  "authentications": {
    "acctAuth": {
      "authType": "oauth2",
      "url": "https://***********",
      "httpMethod": "GETWITHBODY",
      "httpParams": {
        "arguments": {
          "apiKey": "********************************************",
          "logoutCurrentWebConnection": false
        },
        "methodName": "connectWithApiKey",
        "serviceName": "ConnectionService"
      },
      "httpHeaders": {
        "Content-Type": "text/plain"
      },
      "authError": [
        "InvalidAuthenticationToken"
      ],
      "httpContentType": "application/json",
      "errorPath": "error.code",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "result",
      "tokenType": "Bearer",
      "retryFailureStatusCode": [
        401,
        403
      ],
      "accessToken": "Bearer <token>",
      "testConnectionParams": {
        "http": {
          "url": "https://****************************.cfm",
          "httpParams": {
            "arguments": {
              "connectionID": "********************************************"
            },
            "methodName": "getAllUsers",
            "serviceName": "UserService"
          },
          "httpHeaders": {
            "Authorization": "${access_token}"
          },
          "httpContentType": "application/json",
          "httpMethod": "GETWITHBODY"
        },
        "successResponses": {
          "statusCode": [
            200
          ]
        },
        "errors": [
          "Couldn't authenticate you"
        ],
        "errorPath": "error.message"
      }
    }
  }
}



suryavav
New Contributor III
New Contributor III

@sk @rushikeshvartak I tried it using GETWITHBODY and getting below error, which usually receive response from application if provided invalid connection ID or pass null.

responseText:{"result":{"message":"Error: You do not have a valid connection",

suryavav_1-1704476264532.png

 

 

suryavav
New Contributor III
New Contributor III

@sk @rushikeshvartak Any update please. We are still facing the issue.

Please try once with below JSON.

{
  "authentications": {
    "acctAuth": {
      "authType": "oauth2",
      "url": "https://***********",
      "httpMethod": "GETWITHBODY",
      "httpParams": "{\"arguments\":{\"apiKey\": \"********************************************\",\"logoutCurrentWebConnection\": false},\"methodName\": \"connectWithApiKey\",\"serviceName\": \"ConnectionService\"}",
      "httpHeaders": {
        "Content-Type": "text/plain"
      },
      "authError": [
        "InvalidAuthenticationToken"
      ],
      "httpContentType": "application/json",
      "errorPath": "error.code",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "result",
      "tokenType": "Bearer",
      "retryFailureStatusCode": [
        401,
        403
      ],
      "accessToken": "Bearer <token>",
      "testConnectionParams": {
        "http": {
          "url": "https://****************************.cfm",
          "httpParams": "{\"arguments\":{\"connectionID\": \"********************************************\"},\"methodName\": \"getAllUsers\",\"serviceName\": \"UserService\"}",
          "httpHeaders": {
            "Authorization": "${access_token}"
          },
          "httpContentType": "application/json",
          "httpMethod": "GETWITHBODY"
        },
        "successResponses": {
          "statusCode": [
            200
          ]
        },
        "errors": [
          "Couldn't authenticate you"
        ],
        "errorPath": "error.message"
      }
    }
  }
}