NuxeoClient.Client.Request C# (CSharp) Method

Request() public method

Performs a RESTful request to the Nuxeo Server.
public Request ( RequestType type, string endpoint, QueryParams parameters = null, JToken data = null, string>.Dictionary additionalHeaders = null, string contentType = ContentType.JSON ) : Task
type RequestType The type of the request.
endpoint string The end point, following "api/v1/".
parameters QueryParams The query parameters to follow the url.
data JToken The JSON data to be send.
additionalHeaders string>.Dictionary The additional request headers, besides those already specified in the client.
contentType string The type of the content to be sent.
return Task
        public async Task<Entity> Request(RequestType type,
                                          string endpoint,
                                          QueryParams parameters = null,
                                          JToken data = null,
                                          Dictionary<string, string> additionalHeaders = null,
                                          string contentType = ContentType.JSON)
        {
            if (type == RequestType.GET)
            {
                return await Get(UrlCombiner.Combine(RestPath, endpoint), parameters, additionalHeaders, contentType);
            }
            else if (type == RequestType.POST)
            {
                return await Post(UrlCombiner.Combine(RestPath, endpoint), parameters, data, additionalHeaders, contentType);
            }
            else if (type == RequestType.PUT)
            {
                return await Put(UrlCombiner.Combine(RestPath, endpoint), parameters, data, additionalHeaders, contentType);
            }
            else if (type == RequestType.DELETE)
            {
                return await Delete(UrlCombiner.Combine(RestPath, endpoint), parameters, additionalHeaders, contentType);
            }
            else
            {
                throw new Exception("Invalid request type.");
            }
        }