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 connector successResponses checking message in reponse

jeaton3
New Contributor
New Contributor

I have a REST connector and I want to treat two different responses to AddAccessJSON as successful:

200 status code

OR the specific message in the response example from Postman:

 

{
    "error": {
        "code": "openaccess.general.invalidrequestitem",
        "message": "There is already an access level assignment for this access level and badge."
    },
    "version": "1.0"
}

 

I've tried a few combinations of setting successResponse like:

 

"successResponses": [
    "statusCode": [ 200 ],
    "error.message": [ "There is already an access level assignment for this access level and badge." ]
]

 

using different variations like "message" "message.error.message", and "error.message".  

Is there a way to do what I want here?

 

 

7 REPLIES 7

CR
Regular Contributor III
Regular Contributor III

try like below

{
"accountIdPath": "call1.message.user.id"
}

if going to use message property ,above tag should will be der in json then message property will work

https://forums.saviynt.com/t5/identity-governance/servicenow-provisioning-failing-intermittently/m-p...

"successResponses": {
"message": [
"There is already an access level assignment for this access level and badge."
]
}

or


"successResponses": {
"result[0].status": "There is already an access level assignment for this access level and badge"
}


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

jeaton3
New Contributor
New Contributor

I'm sorry, I don't understand your reply.  I need to accept either statusCode 200 or the message "There is already an access level assignment for this access level and badge." 

What do I need to put in successResponses to test for either case?  

You can either use HTTP Status code or Message not both


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

jeaton3
New Contributor
New Contributor

Thank you for the clarification.

Can I validate on two different messages?  Something like:

"successResponses": [
{ "status": "There is already an access level assignment for this access level and badge." },
{ "type_name": "Success" }
]

and ignore the HTTP status code entirely?

jeaton3
New Contributor
New Contributor

I am trying to get it working with just a single successResponses value, and have been unsuccessful.  I have tried:

"successResponses": { "message":"There is already an access level assignment for this access level and badge." }

"successResponses": { "error.message":"There is already an access level assignment for this access level and badge." }

"successResponses": { "response.error.message":"There is already an access level assignment for this access level and badge." }

"successResponses": { "response.error.message":"There is already an access level assignment for this access level and badge." }

"successResponses": { "message": [ "There is already an access level assignment for this access level and badge." ] }

"successResponses": { "error.message": [ "There is already an access level assignment for this access level and badge." ] }

This seems like it should be simple, but I cannot find the correct syntax.

 

My full AddAccessJSON is simply:

{
    "call": [{
            "name": "AccessLevel",
            "connection": "acctAuth",
            "url": "https://xxx:8080/api/access/onguard/openaccess/instances?version=1.0&session_token=${access_token}&type_name=Lnl_AccessLevelAssignment",
            "httpMethod": "POST",
            "httpParams": "{\"property_value_map\": {\"ACCESSLEVELID\": \"${entitlementValue.entitlementID}\",\"BADGEKEY\":\"${account.customproperty1}\"}}",
            "httpHeaders": {
                "Authorization": "${access_token}",
                "Accept": "application/json"
            },
            "httpContentType": "application/json",
            "successResponses": { "message": { "There is already an access level assignment for this access level and badge." } }
        }
    ]
}

when I make the call manually through postman, it returns:

{
    "error": {
        "code": "openaccess.general.invalidrequestitem",
        "message": "There is already an access level assignment for this access level and badge."
    },
    "version": "1.0"
}

and I want Saviynt to treat that as success.

"successResponses": {
"error[0].message": "
There is already an access level assignment for this access level and badge."}


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

Falcon
Saviynt Employee
Saviynt Employee

Disclaimer - This is an AI generated response and feedback will be used to fine tune.

To accommodate both scenarios you described (a 200 status code or a specific message in the response) as success conditions for AddAccessJSON in the Saviynt REST connector, you need to properly format the successResponses section to include both types of successful responses. Based on the guidelines provided in the REST Connector Guide and the scenario you've outlined, here's how you could structure your JSON.

 

{
  "successResponses": [
    {
      "statusCode": [200]
    },
    {
      "responsePath": "error.message",
      "values": ["There is already an access level assignment for this access level and badge."]
    }
  ]
}

 

In this structure:

  • The statusCode key is used to define HTTP status codes that indicate success. In this case, a 200 status code is considered successful.
  • The responsePath and values keys work together to define a successful response based on specific message content within the response body. Here, responsePath specifies the JSON path to the message you're checking for success, and values lists the exact message(s) that indicate a successful operation.

This configuration ensures that the REST connector treats both a 200 status code and the presence of the specified message in the response as indicators of success. Remember, the actual JSON path (error.message in the example) may need to be adjusted based on the exact structure of the API response you're working with.