HttpClientAsyncAliases.

HttpPostAsync(ICakeContext, string, Action<HttpSettings>) Method

Summary

POST the specified resource over HTTP/HTTPS.
Assembly
Cake.Http.dll
Namespace
Cake.Http
Containing Type
HttpClientAsyncAliases

Syntax

public static Task<string> HttpPostAsync(this ICakeContext context, string address, Action<HttpSettings> configurator)

Examples

string responseBody = await HttpPostAsync("https://www.google.com", settings =>
{
   settings.UseBearerAuthorization("1af538baa9045a84c0e889f672baf83ff24")
           .SetContentType("application/json")
           .SetRequestBody("{ \"id\": 123, \"name\": \"Test Test\" }");
});

Attributes

Type Description
AsyncStateMachineAttribute
CakeAliasCategoryAttribute
CakeMethodAliasAttribute

Parameters

Name Type Description
context ICakeContext The context.
address string The URL of the resource to POST.
configurator Action<HttpSettings> The settings configurator.

Return Value

Type Description
Task<string> Content of the response body as a string.