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 - Connection JSON

kmashwini
Regular Contributor
Regular Contributor

Hi All,

Below is the JSON we are using for connection JSON for Rest Connector. We are using basic authentication. We checked in postman it works fine. Please let me know what the issue in below JSON is. In logs getting 400 . In pending task error for create account is "headers":null,"message":{"Message":"A valid session is required for API access.","StackTrace":null},"statusCode":400,"description":null,"status":"Failed"}}.

Connection JSON:

{
"authentications":{
"acctAuth":{
"authType":"Basic",
"url":"https://xxxxxxx/Login",
"httpMethod":"POST",
"httpParams":{

},
"httpHeaders":{

},
"httpContentType":"application/json",
"properties":{
"userName":"xx",
"password":"xxx"
},
"authError":[
"InvalidAuthenticationToken",
"Couldn’t aunthenticate you",
"AuthenticationFailed"
],
"errorPath":"error",
"retryFailureStatusCode":[
401
],
"maxRefreshTryCount":5,
"tokenType":"Basic",
"accessToken":"Basic abcd"
}
}
}

 

In Postman we give below json

In Body / JSON

{
    "username": "xxxx",
    "password": "xx"
}
---------------------
Headers
kmashwini_0-1713965888395.png

 

 

   

20 REPLIES 20

Saathvik
All-Star
All-Star

@kmashwini : in Postman call what is the Authorization you are sending in Header?

Try below JSON

{
    "authentications": {
        "acctAuth": {
            "authType": "Basic",
            "url": "https://xxxxxxx/Login",
            "httpMethod": "POST",
            "httpParams": {
                "userName": "xxxxxx",
                "password": "xxxxx"
            },
            "httpHeaders": {
                "Authorization": "Basic xxxxx",
                "contentType": "application/json"
            },
            "httpContentType": "application/json",
            "authError": [
                "InvalidAuthenticationToken",
                "Couldn’t aunthenticate you",
                "AuthenticationFailed"
            ],
            "errorPath": "error",
            "retryFailureStatusCode": [
                401
            ],
            "maxRefreshTryCount": 5,
            "tokenType": "Basic",
            "accessToken": "Basic abcd"
        }
    }
}

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

kmashwini
Regular Contributor
Regular Contributor

@Saathvik  I am not sending anything in headers , Authorization is there with autogenerated.

kmashwini
Regular Contributor
Regular Contributor

I have tried above JSON which u mentioned but still getting same error. which is 400 .

rushikeshvartak
All-Star
All-Star

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.

kmashwini
Regular Contributor
Regular Contributor
curl --location 'https://xxxx/Login' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic xxxx\
--header 'Cookie: xxxx
' \
--data '{
    "username": "xxx",
    "password": "xxx"
}'

kmashwini
Regular Contributor
Regular Contributor

I have tried below json also , since we are receiving cookie in headers.

{

kmashwini_2-1714049905430.png

This is from Saviynt Logs


"authentications":{
"acctAuth":{
"authType":"Basic",
"url":"xx",
"httpMethod":"POST",
"httpParams":{

},
"properties":{
"userName":"xx",
"password":"xx"
},
"httpHeaders":{
"Content-Type":"application/json"
},
"httpContentType":"application/json",
"expiryError":"ExpiredAuthenticationToken",
"authError":[
"USER_AUTHENTICATION_FAILED"
],
"timeOutError":"error",
"errorPath":"error",
"maxRefreshTryCount":3,
"tokenResponsePath":"#HEADERS#Set-Cookie",
"tokenType":"",
"authHeaderName":"Cookie",
"retryFailureStatusCode":[
401
],
"accessToken":"sdfghjk",
"testConnectionParams":{
"http":{
"url":"xxxx",
"httpHeaders":{
"Content-Type":"application/json"
},
"properties":{
"userName":"xxx",
"password":"xxx"
},
"httpContentType":"application/json",
"httpMethod":"POST"
},
"successResponse":[

],
"successResponsePath":"responseText",
"errorPath":"responseText",
"retryFailureStatusCode":[
401
]
}
}
}
}

 Below is the postman, we are not sending anything in params . Cookie is autogenerated in headers and we receive true as response.

kmashwini_0-1714049570235.png

kmashwini_1-1714049649307.png

 

 

@kmashwini : Please change the "authHeaderName":"Cookie" to "authHeaderName":"Authorization" and check. Also can you please share the curl command of subsequent call you are using in testConnectionParams? I don't think you have to explicitly pass username/password again in testconnection block


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

kmashwini
Regular Contributor
Regular Contributor

In cookie we are getting access token , if we give authorization how it would work . I changed and checked still shows same error .Also we dont have curl command .

kmashwini
Regular Contributor
Regular Contributor

In cookie we are getting two values as response in postman but in Saviynt I could see only one. How to map this in JSON

kmashwini_0-1714054573926.pngkmashwini_1-1714054621185.png

 

{
    "authentications": {
        "acctAuth": {
            "authType": "oauth2",
            "url": "URL",
            "httpMethod": "POST",
            "httpParams": {
                "username": "rushi",
                "password": "xxxxxx"
            },
            "httpContentType": "application/x-www-form-urlencoded",
            "successResponse": [
                200
            ],
            "maxRefreshTryCount": 1,
            "retryFailureStatusCode": [401,400,403,404,500,502,503],
            "tokenResponsePath": "#HEADERS#Set-Cookie",
            "tokenType": "",
            "authHeaderName": "Cookie",
            "access_token": "NGSecure abc"
        }
    }
}

Use above JSON


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

The above JSON also not working, getting same error as 400 in logs

Please share logs


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

kmashwini
Regular Contributor
Regular Contributor

The below is the JSON we are trying, we are getting cookie in logs but still says 400 as error.

JSON:

{

              "authentications":{

                             "acctAuth":{

                                           "authType":"oauth2",

                                           "url":xxx,

                                           "httpMethod":"POST",

                                           "httpParams":{

                                                         

                                           },

                                           "properties":{

                                                          "userName":"xxx",

                                                          "password":"xxxx"

                                           },

                                           "httpHeaders":{

                                                          "Content-Type":"application/json"

                                           },

                                           "httpContentType":"application/json",

                                           "expiryError":"ExpiredAuthenticationToken",

                                           "authError":[

                                                          "USER_AUTHENTICATION_FAILED",

                                                          "false"

                                           ],

                                           "timeOutError":"error",

                                           "errorPath":"error",

                                           "maxRefreshTryCount":3,

                                           "tokenResponsePath":"#HEADERS#Set-Cookie",

                                           "tokenType":"",

                                           "authHeaderName":"Cookie",

                                           "retryFailureStatusCode":[

                                                          401

                                           ],

                                           "accessToken":"sdfghjk",

                                           "testConnectionParams":{

                                                          "http":{

                                                                        "url":xxx,

                                                                        "httpHeaders":{

                                                                        "Content-Type":"application/json"

                                           },

                                                                        "properties":{

                                                                                      "userName":"xxx",

                                                                                      "password":"xxxx"

                                                                        },

                                                                        "httpContentType":"application/json",

                                                                        "httpMethod":"POST"

                                                          },

                                                          "successResponse":[

                                                                       

                                                          ],

                                                          "successResponsePath":"responseText",

                                                          "errorPath":"responseText",

                                                          "retryFailureStatusCode":[

                                                                        401

                                                          ]

                                           }

                             }

              }

}

 

Logs in Saviynt :

2024-04-25T18:26:50+05:30-ecm-rest.RestProvisioningService-http-nio-8080-exec-68-gj8fs-DEBUG-Got Webservice API Response: [headers:[Cache-Control: no-cache, no-store, must-revalidate, Pragma: no-cache, Content-Type: application/json, Expires: -1, Server: , Strict-Transport-Security: max-age=31536000; includeSubDomains; preload, X-ASPNET-VERSION: , X-POWERED-BY: , Date: Thu, 25 Apr 2024 12:56:50 GMT, Content-Length: 100, Set-Cookie=******/; Httponly; Secure], responseText:{"Message":"Failed to deserialize JSON, please ensure it is formatted correctly.","StackTrace":null}, cookies:[NGSecure=rd3o00000000000000000000ffff0a62c81fo4443; path=/; Httponly; Secure], statusCode:400]

[This message has been edited by moderator to disable url hyperlink]

            "access_token": "NGSecure abc"

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

kmashwini
Regular Contributor
Regular Contributor

Already we have tried , still shows same error.

   "access_token": "NGSecure abc"

 

SB
Saviynt Employee
Saviynt Employee

The issue has been fixed after making below changes to Connection JSON.

1. "userName", attribute is case sensitive and was updated to "username".

2. "username":"xx", "password":"xxx" are to be defined under httpParams


Regards,
Sahil

Saathvik
All-Star
All-Star

For reference please share the working JSON because multiple suggestions are provided so trying to see how the final one looks like.


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

SB
Saviynt Employee
Saviynt Employee

@kmashwini can you please share the final JSON we used.


Regards,
Sahil

 

 

{
  "authentications": {
    "acctAuth": {
      "authType": "oauth2",
      "url": "",
      "httpMethod": "POST",
      "httpParams": {},
      "properties": {
        "username": "xxx",
        "password": "xxxx"
      },
      "httpHeaders": {
        "Content-Type": "application/json"
      },
      "httpContentType": "application/json",
      "expiryError": "ExpiredAuthenticationToken",
      "authError": [
        "USER_AUTHENTICATION_FAILED",
        "false"
      ],
      "timeOutError": "error",
      "errorPath": "error",
      "maxRefreshTryCount": 3,
      "tokenResponsePath": "#HEADERS#Set-Cookie",
      "tokenType": "",
      "authHeaderName": "Cookie",
      "retryFailureStatusCode": [
        401
      ],
      "accessToken": "sdfghjk",
      "testConnectionParams": {
        "http": {
          "url": "xxx",
          "httpHeaders": {
            "Content-Type": "application/json"
          },
          "properties": {
            "userName": "xxx",
            "password": "xxxx"
          },
          "httpContentType": "application/json",
          "httpMethod": "POST"
        },
        "successResponse": [],
        "successResponsePath": "responseText",
        "errorPath": "responseText",
        "retryFailureStatusCode": [
          401
        ]
      }
    }
  }
}

 




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

kmashwini
Regular Contributor
Regular Contributor

The below JSON is working JSON.

{
"authentications": {
"acctAuth": {
"authType": "oauth2",
"httpHeaders": {
"Content-Type": "application/json"
},
"authError": [
"Unauthorized",
"Invalid session",
"A valid session is required for API access."
],
"url": xxx,
"httpMethod": "POST",
"httpContentType": "application/json",
"errorPath": "Message",
"maxRefreshTryCount": 5,
"tokenResponsePath": "#HEADERS#Set-Cookie",
"tokenType": "",
"authHeaderName": "Cookie",
"accessToken": "abc",
"httpParams": {
"username": "xxx",
"password": "xxx"
},
"retryFailureStatusCode": [
401,
400
]
}
}
}