我试过用“ping”方法调用Mandrill的API来实现this的最简单情况。答案应该是乒乓球。使用有效的密钥,答复似乎工作。但是,我无法访问响应的内容。如何访问API响应的内容?
的代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
namespace MandrillAPI
{
class Program
{
static void Main(string[] args)
{
string ping = "https://mandrillapp.com/api/1.0/users/ping.json";
string key = "?key=123";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(ping);
HttpResponseMessage response = client.GetAsync(key).Result;
Console.WriteLine(response.ToString());
Console.Read();
}
}
}
如何解压从调用的响应?最终,我需要使用API从服务器收集电子邮件,所以我需要以某种方式保留json对象的结构,以便可以访问电子邮件的详细信息。
你能否详细说明你期望的结果是什么? –