【发布时间】:2014-10-20 23:47:03
【问题描述】:
我正在调用一个 Restful API,它希望我在执行 POST 时传递一个参数回调(一个 URL)。 我用来拨打电话的工具是 RESTSharp。我写了下面的代码
var client = new RestClient("https://services.mywebsite.com/api/v3/");
client.Authenticator = new HttpBasicAuthenticator("Usernamae", "P2$$w0rd");
var request = new RestRequest("myAction", Method.POST);
request.AddHeader("Accept", "application/json");
request.AddParameter("Id", "sid");
request.AddParameter("callback", "http://localhost"); // ????????
request.RequestFormat = DataFormat.Json;
request.AddFile("file", @"e:\MyDocuemnt.pdf");
client.ExecuteAsync(request, response => {
Console.WriteLine(response.Content);
有参数回调的那一行需要我传一个url 我应该在这里传递什么? 结果被传递回提供的回调 URL,我如何才能看到呢?
我的应用程序是一个控制台应用程序,我想在这里捕获结果。
【问题讨论】:
-
您正试图查看发送到回调 URL 的响应,而不是您的 RestRequest 的响应?您是否有一个在该 URL 上侦听的端点?