API Post请求C#URL

时间:2015-11-18 10:56:38

标签: c# web-services rest

我有这个网址 http://www.stuff.com/ws/BIWS/service.php?key=sdf9&type=find&query=funktioner:orsearch(%224804255620%22)

我需要一个" post" -api请求,XML返回数据。 我需要使用帖子,因为限制为〜 2000个字符,我需要在orsearch中发送大量数据。我做错了什么,我该怎么调试呢?

        var clientt = new HttpClient();
        clientt.BaseAddress = new Uri("http://www.stuff.com");
        var request = new HttpRequestMessage(HttpMethod.Post, "/ws/BIWS/service.php?");

         var keyValues = new List<KeyValuePair<string, string>>();
         keyValues.Add(new KeyValuePair<string, string>("key", "sdf9"));
         keyValues.Add(new KeyValuePair<string, string>("type", "find"));
         keyValues.Add(new KeyValuePair<string, string>("query", "funktioner:orsearch('4804255620')"));

         request.Content = new FormUrlEncodedContent(keyValues);

         var response = await clientt.SendAsync(request);
         string content = await response.Content.ReadAsStringAsync();

         // Error wrong key entered or something, but url works fine

0 个答案:

没有答案