diff --git a/src/ReC.Client/Api/BaseCrudApi.cs b/src/ReC.Client/Api/BaseCrudApi.cs
index c5f450d..a6c4cbe 100644
--- a/src/ReC.Client/Api/BaseCrudApi.cs
+++ b/src/ReC.Client/Api/BaseCrudApi.cs
@@ -37,13 +37,13 @@ namespace ReC.Client.Api
/// The payload type.
/// The payload to send.
/// A token to cancel the operation.
- /// if the request succeeds; otherwise, .
- public async Task CreateAsync(T payload, CancellationToken cancel = default)
+ /// Thrown when the API responds with a non-success status code.
+ public async Task CreateAsync(T payload, CancellationToken cancel = default)
{
using (var content = ReCClientHelpers.ToJsonContent(payload))
using (var resp = await Http.PostAsync(ResourcePath, content, cancel))
{
- return resp.IsSuccessStatusCode;
+ await ReCClientHelpers.EnsureSuccessAsync(resp, cancel).ConfigureAwait(false);
}
}
@@ -54,13 +54,13 @@ namespace ReC.Client.Api
/// The resource identifier.
/// The payload to send.
/// A token to cancel the operation.
- /// if the request succeeds; otherwise, .
- public async Task UpdateAsync(long id, T payload, CancellationToken cancel = default)
+ /// Thrown when the API responds with a non-success status code.
+ public async Task UpdateAsync(long id, T payload, CancellationToken cancel = default)
{
using (var content = ReCClientHelpers.ToJsonContent(payload))
using (var resp = await Http.PutAsync($"{ResourcePath}/{id}", content, cancel))
{
- return resp.IsSuccessStatusCode;
+ await ReCClientHelpers.EnsureSuccessAsync(resp, cancel).ConfigureAwait(false);
}
}
@@ -70,8 +70,8 @@ namespace ReC.Client.Api
/// The payload type containing identifiers.
/// The payload to send.
/// A token to cancel the operation.
- /// if the request succeeds; otherwise, .
- public async Task DeleteAsync(T payload, CancellationToken cancel = default)
+ /// Thrown when the API responds with a non-success status code.
+ public async Task DeleteAsync(T payload, CancellationToken cancel = default)
{
using (var request = new HttpRequestMessage(HttpMethod.Delete, ResourcePath)
{
@@ -79,7 +79,7 @@ namespace ReC.Client.Api
})
using (var resp = await Http.SendAsync(request, cancel))
{
- return resp.IsSuccessStatusCode;
+ await ReCClientHelpers.EnsureSuccessAsync(resp, cancel).ConfigureAwait(false);
}
}
}