Back to Home
$httpPatch
$httpPatch sends a PATCH request to an API. Use this when you need to partially update an existing resource. Unlike PUT which replaces the whole thing, PATCH only changes the fields you send.
Syntax
$httpPatch[Url;(Body)]
Url: the web address of the API you are sending data to.(Body): the data you want to send (usually JSON). This is optional, but most APIs expect at least{}if they require a body. Leave it fully empty only if the API explicitly accepts a bodyless request.
What happens
$httpPatchsends your data to the URL.- The API finds the resource and updates only the fields you provided.
- The response is stored in memory. Use $httpResult to see it.
Example 1: Updating only the role
Change a user's role without touching their name or age:
$httpPatch[https://api.example.com/users/1;{"role":"admin"}]
$httpResult
What happens:
$httpPatchsends only the role to the API.- The API updates the user's role and leaves everything else unchanged.
$httpResultdisplays whatever the API returned.
To extract specific parts of the response, see the $httpResult page.
Example 2: Updating multiple fields at once
Change a user's name and age at the same time:
$httpPatch[https://api.example.com/users/1;{"name":"Cenzo","age":25}]
$httpResult
What happens:
$httpPatchsends the name and age to the API.- The API updates only those two fields. Everything else stays the same.
$httpResultshows the response.
Common uses
- Changing a single setting without resending everything
- Updating a user's status or role on a server
- Fixing a typo in a record
- Saving partial form data incrementally
See also
- $httpResult: to read the API's response
- $httpStatus: to check if the update succeeded
- $httpAddHeader: to set content type or send an API key