Table of Contents

Class ResponseMessage

Namespace
Microsoft.Azure.Cosmos
Assembly
Microsoft.Azure.Cosmos.Client.dll

Represents a response from the Azure Cosmos DB service.

public class ResponseMessage : IDisposable
Inheritance
ResponseMessage
Implements
Inherited Members
Extension Methods

Constructors

ResponseMessage()

Create a ResponseMessage

public ResponseMessage()

ResponseMessage(HttpStatusCode, RequestMessage, string)

Create a ResponseMessage

public ResponseMessage(HttpStatusCode statusCode, RequestMessage requestMessage = null, string errorMessage = null)

Parameters

statusCode HttpStatusCode

The HttpStatusCode of the response

requestMessage RequestMessage

The RequestMessage object

errorMessage string

The reason for failures if any.

Properties

Content

Gets the content as a Stream, if any, of the current response.

public virtual Stream Content { get; set; }

Property Value

Stream

ContinuationToken

Gets the Continuation Token in the current ResponseMessage.

public virtual string ContinuationToken { get; }

Property Value

string

Remarks

This is only used in feed operations like query and change feed

Diagnostics

Gets or sets the cosmos diagnostic information for the current request to Azure Cosmos DB service

public virtual CosmosDiagnostics Diagnostics { get; set; }

Property Value

CosmosDiagnostics

ErrorMessage

Gets the reason for a failure in the current response.

public virtual string ErrorMessage { get; }

Property Value

string

Headers

Gets the current ResponseMessage HTTP headers.

public virtual Headers Headers { get; }

Property Value

Headers

IndexMetrics

Gets the Index Metrics in the current ResponseMessage to be used for debugging purposes. It's applicable to query response only. Other feed response will return null for this field. This result is only available if QueryRequestOptions.PopulateIndexMetrics is set to true.

public string IndexMetrics { get; }

Property Value

string

The index utilization metrics.

IsSuccessStatusCode

Asserts if the current HttpStatusCode is a success.

public virtual bool IsSuccessStatusCode { get; }

Property Value

bool

RequestMessage

Gets the original request message

public virtual RequestMessage RequestMessage { get; }

Property Value

RequestMessage

StatusCode

Gets the HttpStatusCode of the current response.

public virtual HttpStatusCode StatusCode { get; }

Property Value

HttpStatusCode

Methods

Dispose()

Disposes the current ResponseMessage.

public void Dispose()

Dispose(bool)

Dispose of the response message content

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

True to dispose of content

EnsureSuccessStatusCode()

Checks if the current ResponseMessage has a successful status code, otherwise, throws.

public virtual ResponseMessage EnsureSuccessStatusCode()

Returns

ResponseMessage

The current ResponseMessage.

Exceptions

CosmosException

An instance of CosmosException representing the error state.