Repository navigation
Closed
Labels
Cost:SWork that requires one engineer up to 1 weekTeam:LibrariesUser StoryA single user-facing feature. Can be grouped under an epic.api-approvedAPI was approved in API review, it can be implementedapi-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Text.Json
Milestone
Description
Background and motivation
It's natural to have PatchAsJsonAsync when we already got PostAsJsonAsync and PutAsJsonAsync.
API Proposal
namespace System.Net.Http.Json
{
public static class HttpClientJsonExtensions
{
public static Task<HttpResponseMessage> PatchAsJsonAsync<TValue>(this HttpClient client, string? requestUri, TValue value, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default);
public static Task<HttpResponseMessage> PatchAsJsonAsync<TValue>(this HttpClient client, Uri? requestUri, TValue value, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default);
public static Task<HttpResponseMessage> PatchAsJsonAsync<TValue>(this HttpClient client, string? requestUri, TValue value, CancellationToken cancellationToken);
public static Task<HttpResponseMessage> PatchAsJsonAsync<TValue>(this HttpClient client, Uri? requestUri, TValue value, CancellationToken cancellationToken);
public static Task<HttpResponseMessage> PatchAsJsonAsync<TValue>(this HttpClient client, string? requestUri, TValue value, JsonTypeInfo<TValue> jsonTypeInfo, CancellationToken cancellationToken = default);
public static Task<HttpResponseMessage> PatchAsJsonAsync<TValue>(this HttpClient client, Uri? requestUri, TValue value, JsonTypeInfo<TValue> jsonTypeInfo, CancellationToken cancellationToken = default);
}
}API Usage
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/vnd.github.v3+json");
var body = new { Sha = "sha" };
var response = await client.PatchAsJsonAsync("https://api.github.com/repos/octocat/hello-world/git/refs/REF", body);
if (response.IsSuccessfulStatusCode)
{
Console.WriteLine("Patched!");
}Alternative Designs
No response
Risks
No response
Metadata
Metadata
Assignees
Labels
Cost:SWork that requires one engineer up to 1 weekTeam:LibrariesUser StoryA single user-facing feature. Can be grouped under an epic.api-approvedAPI was approved in API review, it can be implementedapi-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Text.Json
Activity
eiriktsarpalis commentedon Oct 18, 2021
@ikesnowy thank you for the API proposal. I've marked it ready for review.
bartonjs commentedon Oct 19, 2021
Video
Looks good as proposed
scalablecory commentedon Oct 19, 2021
@bartonjs @eiriktsarpalis the defaults in the proposed API create an ambiguity when calling as
client.PatchAsJsonAsync(uri, value).Removing up-for-grabs, please add back when resolved.
ikesnowy commentedon Oct 20, 2021
@scalablecory
Sorry, I updated the proposal, should be ok now