using CURL in Android

EwoudvdWerfEwoudvdWerf USMember ✭✭✭

I want to execute this curl "command"
$ curl --data "grant_type=authorization_code&code=120340450670" https://example.zportal.nl/api/v3/oauth/token
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("https://cvo-zwfryslan.zportal.nl/api/v3/oauth/token", httpContent);

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

}`

Best Answer

Answers

  • 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.