add method to post StreamContent
This commit is contained in:
parent
2877d62f95
commit
aaaaf283ee
@ -116,4 +116,31 @@ public class EConnectClient<TError> : IEConnectClient<TError> where TError : cl
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<Response<TData, TError>> PostAsync<TData>(StreamContent content, string? route = null, object? queryParams = null, CancellationToken cancel = default)
|
||||||
|
where TData : class
|
||||||
|
{
|
||||||
|
route = AddQueryString(route, queryParams);
|
||||||
|
|
||||||
|
var res = await Http.PostAsync(route, content, cancel);
|
||||||
|
|
||||||
|
if (res.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Ok = true,
|
||||||
|
StatusCode = res.StatusCode
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = await res.Content.ReadFromJsonAsync<TError>(_options.JsonSerializerOptions, cancel);
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Ok = false,
|
||||||
|
StatusCode = res.StatusCode,
|
||||||
|
Error = error
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user