Share via


HttpRequestMessageExtensions.CreateErrorResponse Method (HttpRequestMessage, HttpStatusCode, ODataError)

 

Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of ObjectContent<T> 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 HttpConfiguration.

Namespace:   System.Web.OData.Extensions
Assembly:  System.Web.OData (in System.Web.OData.dll)

Syntax

public static HttpResponseMessage CreateErrorResponse(
    this HttpRequestMessage request,
    HttpStatusCode statusCode,
    ODataError oDataError
)
public:
[ExtensionAttribute]
static HttpResponseMessage^ CreateErrorResponse(
    HttpRequestMessage^ request,
    HttpStatusCode statusCode,
    ODataError^ oDataError
)
static member CreateErrorResponse : 
        request:HttpRequestMessage *
        statusCode:HttpStatusCode *
        oDataError:ODataError -> HttpResponseMessage
<ExtensionAttribute>
Public Shared Function CreateErrorResponse (
    request As HttpRequestMessage,
    statusCode As HttpStatusCode,
    oDataError As ODataError
) As HttpResponseMessage

Parameters

Return Value

Type: System.Net.Http.HttpResponseMessage

An error response wrapping oDataError with status code statusCode.

See Also

HttpRequestMessageExtensions Class
System.Web.OData.Extensions Namespace

Return to top