Custom Vendor Page ‐ Details for PATCH and DELETE methods - kannanmdu/GTK GitHub Wiki
To provide the If-Match
key in a PATCH
or DELETE
request for an API page in Business Central, you need to include the If-Match
header in your HTTP request. The value of the If-Match
header should be the etag
of the record you want to update or delete.
Base URL - https://api.businesscentral.dynamics.com/v2.0/{tenantId}/{environment}/api/GTKIPL/GTKAPI/v2.0/
Incase of Sandbox it will be
https://api.businesscentral.dynamics.com/V2.0/4b12c967-0958-4d5f-ae73-460055fbb27d/Sandbox
Steps:
-
Retrieve the Record's ETag:
- Perform a
GET
request to fetch the record. - The response will include an
@odata.etag
property, which is the ETag of the record.
- Perform a
-
Include the ETag in the
If-Match
Header:- Use the
@odata.etag
value in theIf-Match
header of yourPATCH
orDELETE
request.
- Use the
Example:
Fetch the Record:
GET https://{baseURL}/api/GTKIPL/GTKAPI/v2.0/gtkvendors({SystemId})
Response:
{
"SystemId": "12345",
"@odata.etag": "W/\"JzEtc3lzdGVtLmlkJw==\""
}
Update the Record (PATCH):
PATCH https://{baseURL}/api/GTKIPL/GTKAPI/v2.0/gtkvendors(12345)
Content-Type: application/json
If-Match: W/"JzEtc3lzdGVtLmlkJw=="
{
"Name": "Updated Vendor Name"
}
Delete the Record (DELETE):
DELETE https://{baseURL}/api/GTKIPL/GTKAPI/v2.0/gtkvendors(12345)
If-Match: W/"JzEtc3lzdGVtLmlkJw=="
The If-Match
header ensures that the operation is performed only if the record has not been modified since the ETag was retrieved.