在过去的几个小时里,我一直在尝试编写一个单独的项目来使用API。它的文档/示例是here。
可悲的是,我无法获得" application / json"它的响应,即使是文档中的示例值。这是我的方法的代码,带有示例值(从文档中复制/粘贴)。我尝试了一些修改,但我甚至不知道从哪里开始挖掘。g1 [x] = [x]
responseData 值 - http://pastebin.com/t3EYyP8w
答案 0 :(得分:-1)
我会尝试RestSharp,可以通过Nuget安装它。有一个简单的方法。 http://restsharp.org/
var client = new RestClient("https://Whatever.com/api/");
client.Authenticator = new HttpBasicAuthenticator("Bearer", "YourToken");
//Add the Method you are executing from API
var request = new RestRequest("resource/{id}", Method.POST);
//Add your paramers like this
request.AddParameter("name", "value");
//Json
request.RequestFormat = DataFormat.Json;
//Execute Post
var response = client.execute(request);
//If you want to turn Json into Model
var responseModel = JsonConvert.DeserializeObject<YourObject>(response.Content);