/// <summary>
        /// Creates a new record in the table using the fields provided in the record of type T.
        /// </summary>
        /// <param name="record">The record of Type T to be added to the table in ServiceNow.</param>
        /// <returns>A RestResponse containing a single result of T (if successful) for your newly created record, along with any error messages (if any).</returns>
        public RESTSingleResponse <T> Post(T record)
        {
            var response = new RESTSingleResponse <T>();

            try
            {
                string data = JsonConvert.SerializeObject(record, new ResourceLinkConverter());
                response.RawJSON = ServiceNowClient.UploadString(URL + "?&sysparm_fields=" + _FieldList, "POST", data);
            }
            catch (WebException ex)
            {
                response.ErrorMsg = ParseWebException(ex);
            }
            catch (Exception ex)
            {
                response.ErrorMsg = "An error occured retrieving the REST response: " + ex.Message;
            }

            RESTSingleResponse <T> tmp = JsonConvert.DeserializeObject <RESTSingleResponse <T> >(response.RawJSON);

            if (tmp != null)
            {
                response.Result = tmp.Result;
            }

            return(response);
        }
        /// <summary>
        /// Retrieves a single record contained in the RESTSingleResponse of the type T defined for the table client.<para />
        /// Any errors will be fully captured and returned in the ErrorMsg property of the response.
        /// </summary>
        /// <param name="id">sys_id of the record to be retrieved.</param>
        /// <returns>A RestResponse containing a single result of T (if successful) along with any error messages (if any).</returns>
        public RESTSingleResponse <T> GetById(string id)
        {
            var response = new RESTSingleResponse <T>();

            try
            {
                response.RawJSON = ServiceNowClient.DownloadString(URL + "/" + id + "?&sysparm_fields=" + _FieldList);
            }
            catch (WebException ex)
            {
                response.ErrorMsg = ParseWebException(ex);
            }
            catch (Exception ex)
            {
                response.ErrorMsg = "An error occured retrieving the REST response: " + ex.Message;
            }

            RESTSingleResponse <T> tmp = JsonConvert.DeserializeObject <RESTSingleResponse <T> >(response.RawJSON);

            if (tmp != null)
            {
                response.Result = tmp.Result;
            }

            return(response);
        }
        public RESTSingleResponse <TResult> Put <TResult, TParam>(TParam @params, string id)
        {
            string _params = JsonConvert.SerializeObject(@params, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            var response = new RESTSingleResponse <TResult>();

            _TableName = TableResolver.GetTableName <TResult>();
            var request = new RestRequest(Method.PUT);

            ServiceNowClient.BaseUrl = new Uri($"{URL}/{id}");

            request.AddHeader("accept", "application/json");
            //request.AddHeader("authorization", "Basic T01TX0FwcF9Vc2VyOjBzY2FyOTk=");
            //request.AddHeader("content-type", "application/json");

            request.AddParameter("application/json", _params, ParameterType.RequestBody);

            IRestResponse res = ServiceNowClient.Execute(request);

            if (res.StatusCode != HttpStatusCode.BadRequest)
            {
                RESTSingleResponse <TResult> tmp = JsonConvert.DeserializeObject <RESTSingleResponse <TResult> >(res.Content);
                if (tmp != null)
                {
                    response.Result = tmp.Result;
                }
            }
            return(response);
        }
        public RESTSingleResponse <T> GetRecordById <T>(string id)
        {
            var response = new RESTSingleResponse <T>();

            try
            {
                _TableName = TableResolver.GetTableName <T>();
                var request = new RestRequest(Method.GET);
                ServiceNowClient.BaseUrl = new Uri(URL + "/" + id);
                IRestResponse res = ServiceNowClient.Execute(request);

                if (res.StatusCode == HttpStatusCode.OK)
                {
                    RESTSingleResponse <T> tmp = JsonConvert.DeserializeObject <RESTSingleResponse <T> >(res.Content);
                    if (tmp != null)
                    {
                        response.Result = tmp.Result;
                    }
                }
            }
            catch (WebException ex)
            {
                response.ErrorMsg = ParseWebException(ex);
            }
            catch (Exception ex)
            {
                response.ErrorMsg = "An error occured retrieving the REST response: " + ex.Message;
            }

            return(response);
        }
        public RESTSingleResponse <TResult> Post <TResult, TParam>(TParam @params)
        {
            string _params = JsonConvert.SerializeObject(@params, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            var response = new RESTSingleResponse <TResult>();

            _TableName = TableResolver.GetTableName <TResult>();
            var request = new RestRequest(Method.POST);

            ServiceNowClient.BaseUrl = new Uri(URL);

            request.AddParameter("application/json", _params, ParameterType.RequestBody);

            IRestResponse res = ServiceNowClient.Execute(request);

            if (res.StatusCode != HttpStatusCode.BadRequest)
            {
                RESTSingleResponse <TResult> tmp = JsonConvert.DeserializeObject <RESTSingleResponse <TResult> >(res.Content);
                if (tmp != null)
                {
                    response.Result = tmp.Result;
                }
            }
            return(response);
        }