Skip to content

PostJson / PutJson / PatchJson / DeleteJson

These four write methods are structurally identical, differing only in the RestSharp.Method they pass to the shared HTTP funnel (POST, PUT, PATCH, DELETE). DeleteJson<T> is the only delete overload — there is no body-less DELETE.

Field Value
Operation ID OP-04
Trigger Direct call by a consuming application.
Inputs methodUriSegment, object requestBody.
Outputs ApiResponse<T>.
Primary components JsonHttpClient.PostJson<T>, JsonHttpClient.PutJson<T>, JsonHttpClient.PatchJson<T>, JsonHttpClient.DeleteJson<T>
Entry point src/SAIF.Web.API.Clients/JsonHttpClient.cs

Steps

  1. Execute the HTTP call with the supplied body through the shared funnel.
  2. Embedded logic (BR-CLI-001, BR-CLI-002, BR-CLI-003, BR-CLI-005, BR-CLI-006, BR-CLI-010, BR-CLI-011):
    • Build the client, serialize the body, attach headers, execute, retry, and enforce success.

Origin: This step is implemented in GetJsonResponse (SAIF.Web.API.Clients) and executed on behalf of this operation. - Note: requestBody is not null-checked at this call site; GetJsonResponse skips AddJsonBody when it is null. 2. Project the transport response into ApiResponse<T> (BR-CLI-009, BR-CLI-012, BR-CLI-014).

Origin: This step is implemented in GetApiResponse\<T> (SAIF.Web.API.Clients) and executed on behalf of this operation.

Process flow

flowchart TD
    Start(["PostJson / PutJson /<br>PatchJson / DeleteJson<br>called"]) --> Funnel["Execute call with body<br>via GetJsonResponse"]
    Funnel --> Project["GetApiResponse&lt;T&gt;:<br>project into envelope"]
    Project --> EndOk(["Return<br>ApiResponse&lt;T&gt;"])

Failure and edge-case behavior

  • A null requestBody results in no JSON body being attached to the request rather than an error — valid for calls that carry no payload.
  • Failure handling is identical to the GET-verb methods: a non-2xx/3xx status throws a typed SAIFException when EnsureSuccessfulResponse is enabled.

Sources

  • src/SAIF.Web.API.Clients/JsonHttpClient.cs