Custom policy REST API ValidationTechnicalProfile ContinueOnError not working for HTTP codes like 404 NotFound and 401 unauthorized

跟風遠走 提交于 2021-01-05 11:06:44

问题


In Azure AD B2C custom policy, In a ValidationTechnicalProfile, while calling an external REST API, if the REST API returns HTTP error codes like 404 not found, or 401 unauthorized, the "ContinueOnError" attribute does not take effect. Instead the user journey ends abruptly throwing an error "Unable to validate the information provided" to the user interface in case of a self asserted technical profile. However the ContinueOnError attribute works as expected when the REST API returns error codes such as 400 Bad Request.

<ValidationTechnicalProfiles>
<ValidationTechnicalProfile ReferenceId="REST-API-PostUser" ContinueOnError="true" />

Why is the above not working for certain codes like 404 or 401? Is there any other ways in which we can handles these codes accordingly within the user journey?


回答1:


Rest API validation technical profile with B2C custom policy will work only with 200-ok, 400- Bad Request or 409 -Conflict HTTPStatus code. What I do is catch any error in the REST API controller, if it's written by your team and always throw 409, except for 200 and 400. If it's not written by your team there are two options: 1. Use an API manager (Many available in market) to wrap any other error code to 409 2. Develop your own Web API as wrapper on the third party API that you are calling and then capture any error and throw it back as 409. Read this: https://docs.microsoft.com/bs-latn-ba/azure/active-directory-b2c/restful-technical-profile#returning-error-message



来源:https://stackoverflow.com/questions/55722773/custom-policy-rest-api-validationtechnicalprofile-continueonerror-not-working-fo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!