【发布时间】:2015-03-09 07:23:12
【问题描述】:
我正在使用 mashape api 来获取速度后跟踪信息:-
https://www.mashape.com/blaazetech/indian-post
因为这是在 .NET c# 中,所以下面的代码没有被编译:-
Task<HttpResponse<MyClass>> response = Unirest.get("https://indianpost.p.mashape.com/index.php?itemno=EF990403084IN")
.header("X-Mashape-Key", mykey)
.header("Accept", "application/json")
.asJson();
编译错误是“无法从用法中推断方法 'unirest_net.request.HttpRequest.asJson()' 的类型参数。尝试显式指定类型参数。”
我不确定如何使用这个 api。 “MyClass”有问题吗?
【问题讨论】:
-
顺便说一句,Mashape 提供的语法是错误的。您展示的代码示例是一个异步调用,它缺少类类型。将最后一部分替换为: .asJsonAsync
(); - 请参阅此处了解更多信息(异步部分)unirest.io/net.html - 但作为起点,您可以在下面尝试我的同步 GET 代码以保持简单。总帐。