We have an POST API on Appian that is being called to perform user related task ( add, remove, update, activate, deactivate) based on the data sent to the API. The API works fine as its a Cast and the API response of the Cast is being being sent back to the API initiator. However when there is an error the response is sent as an email alert how can the error be sent as an api response. For eg
There is a problem with task “Deactivate User” in the process “PPL_IG Deactivate User Profile”
Problem: An error occurred in executing an Activity Class.
Details: The user [test.abc] you are trying to deactivate is invalid or does not exist.
Recommended Action: Examine the activity class to correct the error and then resume.
How do i capture the "Details: The user [test.abc] you are trying to deactivate is invalid or does not exist." from the error message received via email?
Discussion posts and replies are publicly visible
Can you validate that the user exists when its a deactivation request ? checking the user id exists in the API before calling the deactivate step would give you confidence that the request is valid.
Yes we can but the response "valid" , "invalid" or any error needs to be reported back as an API response
Are you using a WebAPI to do this activity ? If you are then you can programmatic control the HTTP response and messages going back to the consumer based on the outcome of the validation step.
Yes i am using WEB API to do this activity and my error response is
onError: a!httpResponse( statusCode: 500, headers: { a!httpHeader(name: "Content-Type", value: "application/json"), }, body: a!toJson( { fv!processInfo.pv,
"status"
But this does not report the error back but an empty string
pv": { "deactivateResponse": "", "deactivateUser": [Am i missing something?
The alert you are getting is from the Appian Smart Service in Process - so the process model has generated the alert and presumably the process model instance has now stopped. Presumably the PV's are not filled due to this alert. By validating the userid in the WebAPI you can send the invalid response back to the consumer before calling the process model to deactivate / update users based on the validation you've done in the webAPI. I'll try to knock up some sample code that might help