HttpClient GetStringAsync()抛出异常

时间:2014-08-30 13:20:17

标签: windows windows-phone-8 windows-phone-8.1

我正在使用MediaFire Api我正在使用rest api进行验证当我使用此网址在Chrome海报和fifefox海报时使用'GET'请求响应即将到来并且我实现了相同的槽代码以获得响应但是抛出像

这样的例外
  

指定的值包含无效的HTTP标头字符。   参数名称:名称。

requestUrl = https://www.mediafire.com/api/1.1/user/get_session_token.php?  email=windowsphone654321@gmail.com&password=123456AaAa&application_id=42403&signature=506fbb1e62c51c20e50425022e3bca7dabfecca3&token_version=2
HttpClient httpClient = new HttpClient();
var res = await httpClient.GetStringAsync(requestUrl);

1 个答案:

答案 0 :(得分:0)

 public async Task SendHttpClientRequest( Uri uri )
            {
            try
                {
                HttpClient client = new HttpClient();
                HttpResponseMessage response = await client.GetAsync( uri );
                response.EnsureSuccessStatusCode();
                string responseBody = string.Empty;
                responseBody = await response.Content.ReadAsStringAsync();
                }
            catch ( HttpRequestException e )
                {
                Debug.WriteLine( "\nException Message :{0} ", e.Message );
                }
            }