Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebClient same request works on WinForms but doesn't work on WP7

Here is my code:

    var client = new WebClient();
    client.Headers[HttpRequestHeader.Authorization] = "Basic " +    "SECRETCODE";
    client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded; charset=UTF-8";
    client.Headers[HttpRequestHeader.Host] = "api.quizlet.com";
    client.UploadStringCompleted += ClientOnUploadStringCompleted;

    client.UploadStringAsync(new Uri("https://api.quizlet.com/oauth/token"), "POST", string.Format("grant_type={0}&code={1}&redirect_uri={2}",
        HttpUtility.HtmlEncode("authorization_code"), HttpUtility.HtmlEncode(code), HttpUtility.HtmlEncode(AfterOAuthUrl)));

When I test this code in WinForms, I recieve proper token, but when I use this on WP7, it throws exception: Remote server returned: "Not found". What should I do? Is this the WP certificate problem, or do I have to do something different on WP7?

like image 791
LadislavBohm Avatar asked Feb 19 '26 09:02

LadislavBohm


1 Answers

Okay... Try the following:

client.Headers[HttpRequestHeader.Referer] = "http://api.quizlet.com";

If that doesn't work:

client.Headers[HttpRequestHeader.Referer] = "api.quizlet.com";

In the WP project. Let me know if it doesn't work.

like image 153
Shahar Prish Avatar answered Feb 20 '26 22:02

Shahar Prish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!