public async Task <HttpResponseMessage> CreateNews(string city, string date, NewsClient news) { var authorizationString = GOClient.EncodeTo64(string.Format("{0}:{1}", this.username, this.password)); using (var client = new HttpClient()) { client.BaseAddress = new Uri(this.rootUri); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authorizationString); var uri = GOUriBuilder.BuildDiaryEntryUri(city, date); return(await client.PostAsJsonAsync(uri, news)); } }
public static string BuildAbsoluteDiaryEntryUri(string scheme, string host, int port, string city, string date) { return(string.Format("{0}://{1}:{2}/{3}", scheme, host, port, GOUriBuilder.BuildDiaryEntryUri(city, date))); }