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 - Fail provisioning task based on http code in response?

yusufw
New Contributor III
New Contributor III

I configured a connector to SuccessFactors. In the Update User JSON, the call is configured to mark a response as unsuccessful if the httpCode in the response is 500. But when the call is made and the response has a 500, the UpdateUser task does not fail, it completes successfully, which is incorrect. How can I fix this so that, when there's an error in the response, the Update User task fails.

SuccessFactor's connector Update User JSON:

{
"actions": {
"Update Login": {
"call": [
{
"name": "call3",
"connection": "SFAuth",
"url": "https://api4.successfactors.com/odata/v2/upsert?format=json",
"httpContentType": "application/json",
"httpMethod": "POST",
"httpParams": "{\"__metadata\":{\"uri\":\"PerPhone(phoneType='1234',personIdExternal='${user.username}')\"},\"personIdExternal\":\"${user.username}\",\"phoneType\":\"1234\",\"isPrimary\":false,\"areaCode\":\"${user.phonenumber.substring(0,3)}\",\"phoneNumber\":\"${user.phonenumber.substring(3)}\"}",
"httpHeaders": {
"Authorization": "${access_token}",
"Accept": "application/json",
"X-HTTP-METHOD": "MERGE",
"Content-Type": "application/json"
},
"callCondition": "${user.phonenumber != null}",
"successResponses": {
"d[0].httpCode": [200,201,204]
},
"unsuccessResponses": {
"d[0].httpCode": [400,500]
}
}
]
}
}
}

 Here's snippet from the logs:

"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"\"key\" : \"PerPhone/personIdExternal=19012554,PerPhone/phoneType=4833\", \"status\" : \"ERROR\", \"editStatus\" : null, \"message\" : \"Please set a primary phone number.\\n Failed record info: {PerPhone/personIdExternal=19012554, PerPhone/phoneType=4833, PerPhone/isPrimary=false, PerPhone/areaCode=141, PerPhone/phoneNumber=68771234}. \\n for Key PerPhone/personIdExternal=19012554,PerPhone/phoneType=4833 with the index 0\", \"index\" : 0, \"httpCode\" : 500, \"inlineResults\" : null\n","stream":"stdout","time":"2023-03-31T19:23:14.474013809Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"}\n","stream":"stdout","time":"2023-03-31T19:23:14.474018373Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"]\n","stream":"stdout","time":"2023-03-31T19:23:14.474020613Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"}\n","stream":"stdout","time":"2023-03-31T19:23:14.474022684Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"2023-03-31 19:23:14,474 [quartzScheduler_Worker-5] ERROR rest.RestProvisioningService - callResponseMap: [d:[[key:PerPhone/personIdExternal=19012554,PerPhone/phoneType=4833, status:ERROR, editStatus:null, message:Please set a primary phone number.\n","stream":"stdout","time":"2023-03-31T19:23:14.474237231Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":" Failed record info: {PerPhone/personIdExternal=19012554, PerPhone/phoneType=4833, PerPhone/isPrimary=false, PerPhone/areaCode=141, PerPhone/phoneNumber=68771234}. \n","stream":"stdout","time":"2023-03-31T19:23:14.474242011Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":" for Key PerPhone/personIdExternal=19012554,PerPhone/phoneType=4833 with the index 0, index:0, httpCode:500, inlineResults:null]]]\n","stream":"stdout","time":"2023-03-31T19:23:14.474244701Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"2023-03-31 19:23:14,474 [quartzScheduler_Worker-5] DEBUG rest.RestProvisioningService - showResponse: null\n","stream":"stdout","time":"2023-03-31T19:23:14.474247242Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"2023-03-31 19:23:14,474 [quartzScheduler_Worker-5] DEBUG rest.RestProvisioningService - successResponses key: d[0].httpCode, value: [200, 201, 204]\n","stream":"stdout","time":"2023-03-31T19:23:14.474329093Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"2023-03-31 19:23:14,474 [quartzScheduler_Worker-5] DEBUG rest.RestProvisioningService - successResponseText: 500\n","stream":"stdout","time":"2023-03-31T19:23:14.474347303Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"2023-03-31 19:23:14,474 [quartzScheduler_Worker-5] DEBUG rest.RestProvisioningService - successResponseValues: [200, 201, 204]\n","stream":"stdout","time":"2023-03-31T19:23:14.474352005Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"2023-03-31 19:23:14,474 [quartzScheduler_Worker-5] DEBUG rest.RestProvisioningService - unsuccessResponse key: d[0].httpCode, value: [400, 500]\n","stream":"stdout","time":"2023-03-31T19:23:14.474399615Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"2023-03-31 19:23:14,474 [quartzScheduler_Worker-5] DEBUG rest.RestProvisioningService - unsuccessResponseText: 500\n","stream":"stdout","time":"2023-03-31T19:23:14.474403614Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"2023-03-31 19:23:14,474 [quartzScheduler_Worker-5] DEBUG rest.RestProvisioningService - unsuccessResponseValues: [400, 500]\n","stream":"stdout","time":"2023-03-31T19:23:14.474412189Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"2023-03-31 19:23:14,474 [quartzScheduler_Worker-5] DEBUG rest.RestProvisioningService - doUpdateUserAction - temp.status - Failed\n","stream":"stdout","time":"2023-03-31T19:23:14.474416283Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"2023-03-31 19:23:14,474 [quartzScheduler_Worker-5] DEBUG rest.RestProvisioningService - doBreak: true\n","stream":"stdout","time":"2023-03-31T19:23:14.474439544Z"}"
"ecm-worker","2023-03-31T19:23:14.678+00:00","{"log":"2023-03-31 19:23:14,475 [quartzScheduler_Worker-5] DEBUG rest.RestProvisioningService - Task Response: {\"Update Login\":{\"headers\":{\"Server\":\"BizX\",\"x-correlation-id\":\"6a147c3b-1cb1-4cb2-bcd5-0e9b0a0c2068\",\"X-SF-Correlation-Id\":\"6a147c3b-1cb1-4cb2-bcd5-0e9b0a0c2068\",\"successfactors-immutable-companyid\":\"a5ba4037_5f22_4573_80c5_281942509b17\",\"successfactors-message\":\"X-SF-Correlation-Id, successfactors-sourcetype are missing in request headers\",\"X-Event-ID\":\"EVENT-UNKNOWN-UNKNOWN-ob57areboh0117-20230331152313-5466881\",\"Referrer-Policy\":\"strict-origin-when-cross-origin\",\"Strict-Transport-Security\":\"max-age=31536000;

 From the logs, it looks like the connector detects it's an unsuccessResponse response based on the the unsuccessResponseText, but how do I force the task to fail. 

1 REPLY 1

nimitdave
Saviynt Employee
Saviynt Employee

Please try with success responses values as below:

"successResponses": {
"statusCode": [
200,
201
]
}

And do not give unsuccess responses section