JObject MakePostRequest(Dictionary<string,string> dict, string url )
{
try
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
var body = new
StringContent(JsonConvert.SerializeObject(dict), Encoding.UTF8, "application/json");
var response =
client.PostAsync(url, body).GetAwaiter().GetResult();
var responseString =
response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
return
JObject.Parse(responseString);
}
catch (Exception e)
{
Console.WriteLine("Error : " + e.ToString());
}
return JObject.Parse("{}");
}
No comments:
Post a Comment