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 - Unable to map Response status field

piyushm
Regular Contributor II
Regular Contributor II

Hello,

I have a REST application where the status code is 200 even if there is any failure or bad request.

 

The status field in the response is either "Failed" or "Success". Below is the response for one failed scenario. 

{
"Id": "",
"status": "Failed",
"errorMessage": "'First Name' is a required field. Please enter a value for the field.(SBL-DAT-00498)",
"errorCode": "SBL-CREATEUSER-002"
}

In this case I need to map it to the "status" attribute from the response. I tried using different combinations such as

"successResponses":{

"response.status": "Success"

}

"successResponses":{

"message.status": "Success"

}

"successResponses":{

"message.status": ["Success"]

}

But these are not working and the task gets completed.

4 REPLIES 4

rushikeshvartak
All-Star
All-Star

"successResponses":{

"status": ["Success"]

}


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

Vedanth-BK
Regular Contributor
Regular Contributor

Hi @piyushm 

Please try with the below snippet

  "unsuccessResponses": {
    "status": [
      "Failed"
    ]
  }
Thank you
Vedanth B.K

CR
Regular Contributor III
Regular Contributor III

@piyushm 

try below:

"successResponses": {
"statusCode": [
200,
201,
204,
205
]
"message":["succes"]
},
"unsuccessResponses": {
"message": [
"You must be an admin to add or update an organization membership.",
"Not Found"
]
}
}


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

piyushm
Regular Contributor II
Regular Contributor II

This works 

"successResponses":{

"status": ["Success"]

}

 

Also, need to note that for this to work in my case, I had to remove  statusCode within successResponses and remove the Unsuccessresponses block altogether. So anything which does not equal "Success" will be considered as failed.