Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

I am getting System.null reference exception

$
0
0

new KeyValuePair<string, string>("grant_type","password"),
new KeyValuePair<string, string>("username",username),
new KeyValuePair<string, string>("password",password)
};
var request = new HttpRequestMessage(HttpMethod.Post, "http://somesite.com/Token");
request.Content = new FormUrlEncodedContent(keyValues);

        var client = new HttpClient();
        var response = await client.SendAsync(request);
        var jwt = await response.Content.ReadAsStringAsync();
        var jwtDynamic = new JObject();
        jwtDynamic = JsonConvert.DeserializeObject<dynamic>(jwt);

        //dynamic jwtDynamic = JsonConvert.DeserializeObject(jwt);

        var accessToken = jwtDynamic.Value<string>("access_token");
        var accessExpires = jwtDynamic.Value<DateTime>(".expires");

        Debug.WriteLine(jwt);

        return accessToken;

It is breaking at var response


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>