SDK
SDK C# v2.x
2

query #

Base method used to send queries to Kuzzle, following the API Documentation.

This is a low-level method, exposed to allow advanced SDK users to bypass high-level methods.

Arguments #

Copied to clipboard!
public ConfiguredTaskAwaitable<Response> QueryAsync(JObject query)

Argument Type Description
query
JObject
API request

query #

All properties necessary for the Kuzzle API can be added in the query object. The following properties are the most common.

Property Type Description
controller
string
Controller name (mandatory)
action
string
Action name (mandatory)
body
JObject
Query body for this action
index
string
Index name for this action
collection
string
Collection name for this action
_id
string
id for this action
volatile
JObject
Additional information to send to Kuzzle

Returns #

Returns a Response object which represent a raw Kuzzle API response. See the API Documentation.

Usage #

Copied to clipboard!
JObject request = JObject.Parse(@"{
  controller: 'document',
  action: 'create',
  index: 'nyc-open-data',
  collection: 'yellow-taxi',
  _id: 'my-custom-document-id',
  refresh: 'wait_for',
  body: {
    trip_distance: 4.23,
    passenger_count: 2
  }
}");
Response response = await kuzzle.QueryAsync(request);
Console.WriteLine(response.ToString());
/*
  { requestId: '49ffb6db-bdff-45b9-b3f6-00442f472393',
    status: 200,
    error: null,
    controller: 'document',
    action: 'create',
    collection: 'yellow-taxi',
    index: 'nyc-open-data',
    volatile: { sdkName: 'csharp@2.0.0' },
    room: '49ffb6db-bdff-45b9-b3f6-00442f472393',
    result:
      { _id: 'my-custom-document-id',
        _version: 1,
        result: 'created',
        _source:
        { trip_distance: 4.23,
          passenger_count: 2,
          _kuzzle_info:
            { author: '-1',
              createdAt: 1532529302225,
              updatedAt: null,
              updater: null } } } }
*/
Console.WriteLine("Document created");