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

Getting 401 unauthorized error for Accounts imports.

sumalatham
New Contributor
New Contributor
Hello Team
 
Getting 401 unauthorized error for Accounts imports.
 
We are trying to integrating one application with REST Connector, but problem here is AccEntImportJSON and ConnectionJSON is not working. But while testing connection, connection is Successful. In postman we are getting the ticket value as a response, but if we use the below Connection JSON it's failing.
 
ConnectionJSON:
{
  "authentications": {
    "acctAuth": {
      "authType": "oauth2",
      "httpHeaders": {
        "Content-Type": "application/json"
      },
      "authError": [
        "InvalidAuthenticationToken",
        "Authentication_MissingOrMalformed"
      ],
      "url": "https://xxxx/api/auth/login",
      "httpMethod": "POST",
      "httpContentType": "application/json",
      "properties": {
        "account": "test123",
        "password": "xxxx"
      },
      "errorPath": "error.code",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "data.token",
      "tokenType": "",
      "accessToken": "ABCD"
    }
  }
}
 
AccountImportJSON:
{
"accountParams": {
"connection": "acctAuth",
"processingType": "SequentialAndIterative",
"statusAndThresholdConfig": {
"statusColumn": "customproperty10",
"activeStatus": [
"true"
],
"deleteLinks": true,
"accountThresholdValue": 10,
"correlateInactiveAccounts": false,
"inactivateAccountsNotInFile": true,
"deleteAccEntForActiveAccounts": true
},
"call": {
"call1": {
"callOrder": 0,
"stageNumber": 0,
"http": {
"httpHeaders": {
"token": "${token}",
"Content-Type": "application/json"
},
  "httpContentType": "application/json",
"httpMethod": "POST"
},
"httpParams": {
   "active":true
},
    "listField": "data",
"keyField": "id",
"statusConfig": {
"active": "true",
"inactive": "false"
},
"colsToPropsMap": {
"id": "id~#~char",
"name": "account~#~char",
"displayName": "display_name~#~char",
"customproperty1": "first_name~#~char",
"customproperty2": "last_name~#~char",
"customproperty3": "email~#~char",
"customproperty4": "azure_account~#~char",  
"status": "active~#~char"  
}
}
}
}
 
 
Login API:
Request:
{
  "account": "test123",
  "password": "xxxx"  
}
 
Response:
{
    "success": true,
    "code": 0,
    "message": null,
    "data": {
        "id": "12333",
        "account": "test123fsdf",
        "token": "74255424524211",
        "active": true,
        "roles": [
            {
                "id": "12333",
                "priority": 1,
                "country": "US",
                "region": "US"
 
}]
}
}
 
AccountImport API:
Request:
Headers:
token : <from the above one>
Content-Type : application/json
Body:{"active":true}
 
Response
{
    "success": true,
    "code": 0,
    "message": null,
    "data": [
        {
            "id": "243455",
            "account": "test-ext",
            "token": null,
            "active": true,
            "roles": [
                {
                    "id": "611e111021ea795f3
}]
}]
}
 
I had tried multiple ways with multiple combination like below
ConnectionJson
"tokenResponsePath": "token"
"tokenResponsePath": "data.token"
"tokenResponsePath": "response.completeResponseMap.data.token"
"tokenResponsePath": "response.data.token"
 
 
Importjson
 "token": "${access_token}"
  "token": "${token}"
   "token": "${data.token}"
   
Logs:
responseText:{\"success\":\"false\",\"code\":\"401\",\"message\":\"Unauthorized\"}, cookies:[], statusCode:401]\n
 
Note:Postman credentials and Connectionjson credentials are same.
 
Please can you help on this.
 
Thanks
Sumalatha 

 

3 REPLIES 3

SB
Saviynt Employee
Saviynt Employee

In order to check for a successful test connection for REST connection, you need to add the testConnectionParams block. Without this, the app only checks for the JSON format and does not actually make a call to target. You can refer the below REST documentation for the JSON to add testConnectionParams  and check to ensure your Connection JSON is working. 

https://docs.saviyntcloud.com/bundle/REST-v23x/page/Content/Examples-for-JSON-Construction.htm

You can also refer to the Examples for JSON Construction or Developers Handbook section for examples on JSON and how to configure it.

For REST connections, you can update ConfigJSON param in the REST connection with value {"showLogs":true}.
This will enable additional logging and is helpful at times with throubleshooting..


Regards,
Sahil

rushikeshvartak
All-Star
All-Star

Please provide screenshot of postman,

Does import works if you hardcode token. if token is defined in connection then you need to refer in import json as ${connection.token} if its static


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

IAM-Vaibhav
New Contributor III
New Contributor III

Can you try this by putting header in import json instead of token:

"Authorization":"${access_token}" 

if this doesn't work share the screen shot of Postman header section with auto generated headers.