Forum Xamarin Xamarin.Android

using CURL in Android

EwoudvdWerfEwoudvdWerf USMember ✭✭✭

I want to execute this curl "command"
$ curl --data "grant_type=authorization_code&code=120340450670"
in Android, but I don't know how exactly, I have tried this:
`using (var client = new HttpClient())
string content = "grant_type=authorization_code&code=120340450670";
StringContent httpContent = new StringContent(content);

var response = await client.PostAsync("", httpContent);

if (response.IsSuccessStatusCode)
    var responseContent = await response.Content.ReadAsStringAsync();
    Toast.MakeText(Activity, responseContent, ToastLength.Long).Show();
    Toast.MakeText(Activity, "error!", ToastLength.Long).Show();


Best Answer


  • EwoudvdWerfEwoudvdWerf USMember ✭✭✭

    Also it's worth noting that the code used here (this code :120340450670), is an example and probably doesn't work when debugging

  • EwoudvdWerfEwoudvdWerf USMember ✭✭✭
    edited April 2017

    @AlbertK thank you this worked!

  • EwoudvdWerfEwoudvdWerf USMember ✭✭✭

    I found this working example in HTML, this could make it easier to recreate in C#

Sign In or Register to comment.