【发布时间】:2014-01-09 19:30:40
【问题描述】:
我正在尝试在下面的链接中使用示例 api 调用请检查链接
http://sendloop.com/help/article/api-001/getting-started
我的帐户是“code5”,所以我尝试了 2 个代码来获取 systemDate。
1.代码
var request = WebRequest.Create("http://code5.sendloop.com/api/v3/System.SystemDate.Get/json");
request.ContentType = "application/json; charset=utf-8";
string text;
var response = (HttpWebResponse)request.GetResponse();
using (var sr = new StreamReader(response.GetResponseStream()))
{
text = sr.ReadToEnd();
}
2.代码
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://code5.sendloop.com/api/v3/System.SystemDate.Get/json");
httpWebRequest.Method = WebRequestMethods.Http.Get;
httpWebRequest.Accept = "application/json";
但我不知道我上面的代码是否正确使用了api?
当我使用上述代码时,我看不到任何数据或任何东西。
如何获取 api 并将其发布到 Sendloop。如何通过 WebRequest 使用 api?
我将第一次在 .net 中使用 api 所以
我们将不胜感激。
谢谢。
【问题讨论】:
-
此端点是否接受 GET 或 POST 或两者都接受?
-
我想我需要获取该链接中的 api 示例。但我将来也需要发布。所以如果你帮助我,我会很高兴先生。
标签: c# .net api webrequest