AdysTech.InfluxDB.Client.Net.InfluxDBClient.PostAsync C# (CSharp) Метод

PostAsync() приватный Метод

private PostAsync ( string>.Dictionary EndPoint, ByteArrayContent requestContent ) : Task
EndPoint string>.Dictionary
requestContent ByteArrayContent
Результат Task
        private async Task<HttpResponseMessage> PostAsync (Dictionary<string, string> EndPoint, ByteArrayContent requestContent)
        {

            var querybaseUrl = new Uri ($"{InfluxUrl}/write?");
            var builder = new UriBuilder (querybaseUrl);

            if (!EndPoint.ContainsKey ("u"))
                EndPoint.Add ("u", InfluxDBUserName);
            if (!EndPoint.ContainsKey ("p"))
                EndPoint.Add ("p", InfluxDBPassword);
            builder.Query = await new FormUrlEncodedContent (EndPoint).ReadAsStringAsync ();


            try
            {
                HttpResponseMessage response = await _client.PostAsync (builder.Uri, requestContent);

                if (response.StatusCode == HttpStatusCode.Unauthorized || response.StatusCode == HttpStatusCode.BadGateway || (response.StatusCode == HttpStatusCode.InternalServerError && response.ReasonPhrase == "INKApi Error")) //502 Connection refused
                    throw new UnauthorizedAccessException ("InfluxDB needs authentication. Check uname, pwd parameters");

                return response;
            }
            catch (HttpRequestException e)
            {
                if (e.InnerException.Message == "Unable to connect to the remote server")
                    throw new ServiceUnavailableException ();
            }
            return null;
        }