Can anyone let me know how to throw 500 internal error in api response with REST API? i have used below right now:
throw new NoSuchEntityException(
__(
'Field : '.$fields.' required.'
));
but it throws error code 400, i need 500 error code exactly default magento throws error if key is wrong in parameter.
I have used below code: if (!isset($postData[$fields])) { throw new \Magento\Framework\Webapi\Exception( __( 'Field : '.$fields.' has wrong value.' ), 0, \Magento\Framework\Webapi\Exception::HTTP_INTERNAL_ERROR); }