Last active
March 24, 2017 11:31
-
-
Save jfversluis/b2378a0af9e5805b130b3793e28fcbb9 to your computer and use it in GitHub Desktop.
Implementing a POST method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IRestClient.cs | |
[Post ("/posts")] | |
Task AddPost (Foo foo); | |
// RestClient.cs | |
public async Task AddPost (Foo foo) | |
{ | |
await _restClient.AddPost (foo); | |
} | |
// Code-behind | |
private async void Handle_Clicked_Awesome_Post (object sender, System.EventArgs e) | |
{ | |
var foo = new Foo { | |
id = 1337, | |
title = "Awesome!", | |
body = "Unicorns and rainbows", | |
userId = 1 | |
}; | |
await _restClient.AddPost (foo); | |
ResultLabel.Text = $"Added"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment