示例#1
0
        /// <summary>
        /// Sets the AuthToken and TenantId for use in the body of a PUT
        /// </summary>
        /// <param name="x">PutViewModel to have properties set</param>
        /// <returns>PutViewModel with properties set</returns>
        protected PutViewModel SetupPutRequestAuthorizations(PutViewModel x)
        {
            x.TenantId  = _appSettings.TenantId;
            x.AuthToken = _appSettings.AuthToken;

            return(x);
        }
示例#2
0
        /// <summary>
        /// Executes a Put Request to the API
        /// </summary>
        /// <param name="request">RestRequest Object that has had the endpoint set</param>
        /// <param name="x">Object that has had data set to be passed into the request body</param>
        /// <returns>String content of the response for output</returns>
        public string PutRequest(RestRequest request, PutViewModel x)
        {
            //sets up the client and the base URL
            var client = new RestClient();

            client = SetupClientURL(client);

            //Setting the authtoken and tenantID in private method
            x = SetupPutRequestAuthorizations(x);

            //Set appropriate request properties
            request.Method = Method.PUT;
            request.AddHeader("Content-Type", "application/json");
            request.AddJsonBody(x);

            IRestResponse response = client.Execute(request); //execures request

            return(response.StatusDescription);
        }