You need to sign in to do that
Don't have an account?

Send HTTP status code back ,[200, 500]
Hi All,
A third party sends notification data as parameters to our url , on verifying the data we either send HTTP status 200 OK on success or 500 Internal error otherwise.
How do we go about changing the HTTP status code when returning the pagereference in salesforce.
public PageReference initConfirmation(){
respRES = System.currentPagereference().getParameters().get('RES');
if( validate(respRES ) ){
//send back HTTPSTATUS CODE 200
//return null;
}else{
//Send back HTTP STATUS CODE 500
// PageReference pref = ApexPages.currentPage(); // do something
}
}
Kind regards,
Rohini H
You would have to use a RestResource annotation and call it directly as a web service. As far as I'm aware, salesforce.com always generates a 200 OK request, even when an exception is thrown, etc. Using RestContext.response, you can specify a statusCode of any value that is accepted on the Internet, including 2xx, 3xx, 4xx, and 5xx messages.