本文整理汇总了C#中RestClient.PostAsync方法的典型用法代码示例。如果您正苦于以下问题:C# RestClient.PostAsync方法的具体用法?C# RestClient.PostAsync怎么用?C# RestClient.PostAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RestClient
的用法示例。
在下文中一共展示了RestClient.PostAsync方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_post_bson
public async Task Should_post_bson()
{
using (var server = TestServer.Create<Startup>())
{
var restClient = new RestClient(server.HttpClient);
var id = await restClient.PostAsync<int>("/api/foos", new Foo(), MediaTypes.ApplicationJson, MediaTypes.ApplicationJson);
id.ShouldEqual(1);
}
}
示例2: OnNavigatedTo
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.Parameter is VoiceCommandActivatedEventArgs)
{
var args = e.Parameter as VoiceCommandActivatedEventArgs;
var speechRecognitionResult = args.Result;
var command = speechRecognitionResult.Text;
statusMessage.Text = string.Format("Esecuzione del comando {0}...", command);
var action = speechRecognitionResult.RulePath.FirstOrDefault();
var turnOn = (action == "turnOn");
var semanticProperties = speechRecognitionResult.SemanticInterpretation.Properties;
// Figure out the color.
var color = string.Empty;
if (semanticProperties.ContainsKey("colors"))
color = semanticProperties["colors"][0];
var rgb = this.GetRgb(color, turnOn);
using (var client = new RestClient(SERVICE_URL))
{
try
{
await client.PostAsync("led/set", rgb);
statusMessage.Text = "Comando inviato con successo.";
}
catch (Exception ex)
{
statusMessage.Text = "Errore durante l'invio del comando: " + ex.Message;
}
}
}
}
示例3: CreateResource_Succeeds
public async Task CreateResource_Succeeds()
{
// Arrange
var client = new RestClient(_baseAddress);
//var data = _mock.Object;
var data = new Post { Title = "foo", Body = "bar", UserId = "1" };
// Act
var response = await client.PostAsync(new Uri("posts", UriKind.Relative), data);
// Assert
Assert.IsTrue(response.Succeeded);
Assert.AreEqual(response.Data.Title, data.Title);
Assert.AreEqual(response.Data.Body, data.Body);
Assert.AreEqual(response.Data.UserId, data.UserId);
//mockService.Verify(x => x.GetAll(), Times.Once());
}
示例4: Should_post_json_with_parameters
public async Task Should_post_json_with_parameters()
{
using (var server = TestServer.Create<Startup>())
{
var restClient = new RestClient(server.HttpClient);
var parameters = new Dictionary<string, string> { { "param1", "value1" }, { "param2", "value2" } };
var id = await restClient.PostAsync<int>("/api/foos", new Foo(), MediaTypes.ApplicationJson, null, parameters);
id.ShouldEqual(1);
}
}
示例5: Should_post_form_url_encoded_content
public async Task Should_post_form_url_encoded_content()
{
using (var server = TestServer.Create<Startup>())
{
var restClient = new RestClient(server.HttpClient);
var values = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("SomeInt", "1") };
var content = new FormUrlEncodedContent(values);
var id = await restClient.PostAsync<int>("/api/foos", content, MediaTypes.FormUrlEncoded, null);
id.ShouldEqual(1);
}
}
示例6: SendRoverCommandAsync
private async Task SendRoverCommandAsync(RoverMovementType command)
{
using (var client = new RestClient(SERVICE_URL))
{
try
{
await client.PostAsync("rover/move", new RoverMovement { Movement = command });
}
catch (Exception ex)
{
var dialog = new MessageDialog($"Error sending commnad: {ex.Message}");
await dialog.ShowAsync();
}
}
}
示例7: SendJukeboxCommandAsync
private async Task SendJukeboxCommandAsync(string command)
{
using (var client = new RestClient(SERVICE_URL))
{
try
{
await client.PostAsync($"jukebox/{command}");
}
catch (Exception ex)
{
var dialog = new MessageDialog($"Error sending commnad: {ex.Message}");
await dialog.ShowAsync();
}
}
}