Class JsonResponse
Encapsulates the response returned from a JsonClient server call.
Namespace: Neon.Net
Assembly: Neon.Common.dll
Syntax
public class JsonResponse
Constructors
JsonResponse(string, string, HttpResponseMessage, string)
Constructs a JsonResponse from a lower level HttpResponseMessage.
Declaration
public JsonResponse(string requestUri, string requestMethod, HttpResponseMessage httpRespose, string responseText)
Parameters
Type | Name | Description |
---|---|---|
string | requestUri | The request URI. |
string | requestMethod | The request method. |
HttpResponseMessage | httpRespose | The low-level HTTP response. |
string | responseText | The response text. |
Properties
HttpResponse
Returns the low-level HTTP response.
Declaration
public HttpResponseMessage HttpResponse { get; }
Property Value
Type | Description |
---|---|
HttpResponseMessage |
IsSuccess
Returns true
if the response status code indicates success.
Declaration
public bool IsSuccess { get; }
Property Value
Type | Description |
---|---|
bool |
JsonText
Returns the response as JSON text or null
if the server didn't
respond with JSON.
Declaration
public string JsonText { get; }
Property Value
Type | Description |
---|---|
string |
RequestMethod
Returns the request method.
Declaration
public string RequestMethod { get; }
Property Value
Type | Description |
---|---|
string |
RequestUri
Returns the request URI.
Declaration
public string RequestUri { get; }
Property Value
Type | Description |
---|---|
string |
StatusCode
Returns the HTTP response status code.
Declaration
public HttpStatusCode StatusCode { get; }
Property Value
Type | Description |
---|---|
HttpStatusCode |
Methods
AsDynamic()
Returns the dynamic JSON response document, array, value or null
if the server didn't return
JSON content.
Declaration
public dynamic AsDynamic()
Returns
Type | Description |
---|---|
dynamic | The dynamic document or |
As<TResult>()
Converts the response document to a specified type or null
if the server didn't
return JSON content.
Declaration
public TResult As<TResult>()
Returns
Type | Description |
---|---|
TResult | The converted document or its default value. |
Type Parameters
Name | Description |
---|---|
TResult | The specified type. |
EnsureSuccess()
Ensures that the status code indicates success by throwing an exception for any error related status codes.
Declaration
public void EnsureSuccess()
Exceptions
Type | Condition |
---|---|
HttpException | Thrown if the response doesn't indicate success. |