function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dai tran 6dai tran 6 

Why can't access rest api from xamarin?

I access rest api from xamarin:
       HttpClient    client = new HttpClient();
       var RestUrl = "";
            var uri = new Uri(string.Format(RestUrl, string.Empty));          
            UserInfo us = new UserInfo();
            us.grant_type = "password";
            us.client_id = "3MVG9YDQS5WtC11oHZF7qKDt4DyviHkb06byPkwfg_IqruHnLswqi6U23IXZUtGqGW4.ouwAaBxwxf.....";
            us.client_secret = "4085120398336......";
            us.username = "";
            us.password = "123456dHfSkURI2khlRYpOoq7u.....";
            var json = JsonConvert.SerializeObject(us);
            var content = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync(uri, content);

**Result: **
_StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:_

In android, i using okhttp,it is ok. But In xamarin, i using httpclient, it can't.
How can access salesforce Rest API from xamarin?