Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static HttpResponseMessage PostRequest(string json, string url)
- {
- Task<HttpResponseMessage> task = Task.Run(async () => await PostRequestAsync(json, url));
- task.Wait();
- return task.Result;
- }
- private static async Task<HttpResponseMessage> PostRequestAsync(string json, string url)
- {
- try
- {
- HttpResponseMessage response = await client.PostAsync(url, new StringContent(json, Encoding.UTF8, "application/json"));
- return response;
- }
- catch (HttpRequestException exc)
- {
- ThreadKill();
- Console.WriteLine(exc.InnerException.Message);
- Console.WriteLine("Press enter to exit...");
- Console.ReadLine();
- Environment.Exit(1);
- return new HttpResponseMessage();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement