private void SetRequestHeaders(string tcHost, string tcUserName, string tcPassword, int tnTimeout) { request = WebRequest.Create(tcHost) as HttpWebRequest; request.Host = tcHost; request.Headers.Remove("Accept"); request.Headers.Add("Accept", "application/json"); string authorizationKey = Convert.ToBase64String( System.Text.ASCIIEncoding.ASCII.GetBytes( string.Format("{0}:{1}", tcUserName, tcPassword))); request.Headers.Add("Authorization", "Basic " + authorizationKey); request.Timeout = tnTimeout * 1000; }This is the method I'd like to call before trying to get a response. The question is - my actual API url should be appened to the tcHost above. What should I do with the request variable above (assuming it's working - I haven't tested yet) to use the actual API url such as
"/integrationapi//Attraction/Tickets/Validate"
Thanks in advance.>>static async Task<HttpResponseMessage> GetResponse(TicketUsageRequests ticket, string apiUrl) >> { >> HttpResponseMessage response = await client.PostAsJsonAsync(apiUrl, ticket); >> //response.EnsureSuccessStatusCode(); >> >> return response; >> }>>
>>try >> { >> SetRequestHeaders(tcHost, tcUserName, tcPassword, tnTimeout, tnRetries); >> >> TicketUsageRequests ticket = new TicketUsageRequests(); >> ticket.TicketBarcode = tcBarcode; >> ticket.TicketUsageDate = tcUsageDate; >> ticket.UserID = tcUserName; >> >> ... here I want to get the result of the response and parse it >> >> ... >>>>