HttpRequestMessageExtensions.CreateErrorResponse Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Helper method that performs content negotiation and creates a HttpResponseMessage
representing an error with an instance of System.Net.Http.ObjectContent`1 wrapping
oDataError
as the content. If no formatter is found, this method returns a response with
status 406 NotAcceptable.
This method requires that request
has been associated with an instance of
System.Web.Http.HttpConfiguration.
public static System.Net.Http.HttpResponseMessage CreateErrorResponse (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, Microsoft.OData.ODataError oDataError);
static member CreateErrorResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * Microsoft.OData.ODataError -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateErrorResponse (request As HttpRequestMessage, statusCode As HttpStatusCode, oDataError As ODataError) As HttpResponseMessage
Parameters
- request
- HttpRequestMessage
The request of interest.
- statusCode
- HttpStatusCode
The status code of the created response.
- oDataError
- ODataError
The OData error to wrap.
Returns
An error response wrapping oDataError
with status code statusCode
.