PATCH Method
- Last UpdatedJul 01, 2024
- 3 minute read
The PATCH method is used to update an existing resource. It specifies only the changes and does not replace the entire resource.
The supported operations are add, remove, replace, move, and copy.
For more information on operations and the examples, see https://docs.microsoft.com/en-us/aspnet/core/web-api/jsonpatch?view=aspnetcore-3.1
You can use the PATCH method to update the configuration in Web API and Open API. For Web API, you can define the parameters only in the Parameters tab available based on the Request URL value. For Open API, you can define the parameters in the Parameters tab and Body tab.
Parameters Tab
Under this tab, if the Patch has any parameters, then those will be listed.
The table describes the fields available under Parameters tab.
|
Fields |
Description |
|---|---|
|
No |
It displays the serial number of the parameter and represents its sequence. |
|
Optional |
It displays YES or NO values. YES, denotes that you can either enter the value for the parameter in the Value field or leave it blank. NO, denotes that you must enter the value for the parameter in the Value field. Note: For the path parameter, the Optional field is always NO, but for query parameter it can be either YES or NO. |
|
Name |
It displays the name of the parameter. |
|
Data type |
It displays the data type of the parameter. The supported data types are boolean, decimal, numeric, and string. Note: The OpenAPI-specific datatype formats are not validated. |
|
Value |
Enter the value to be passed for the parameter. The value is validated against the data type. The value can be hard-coded or can be passed through the Expression Editor. Note: The value passed using Expression Editor is not validated for the data type. |
Body Tab
This tab is used to pass PostData to the Web API, and the PostData can be passed as raw format or in the form of parameters, hence two options - Parameters and Raw are available with the Radio buttons.
Both Parameters and Raw are validated based on the selection of Content Type.
Note: It is mandatory to provide data either in the Parameters or the Raw option.
Parameters:
In this tab, you can specify only one PATCH operation.
The request body is populated in the form of the value, path, and op to map individual parameters with a hard-coded value or to a dynamic value that is build-up through the Expression Editor.
The table describes the fields available under Body tab for Parameters:
|
Fields |
Description |
|---|---|
|
value |
Enter the property value or an object value. Note: The value passed using Expression Editor is not validated for the data type. |
|
operationType |
The OpenAPI specifications has this property, but is not applicable. |
|
path |
Enter the path of an array element or a property. |
|
op |
Enter the operation like add, remove, replace, move, or copy that you want to perform. |
Raw:
In this tab, you can provide raw data as PostData, either a hard-coded value or dynamic value that is built up through the Expression Editor.
The table describes the fields available to provide Raw data:
|
Fields |
Description |
|---|---|
|
Post Data |
Enter the operations with the property value or an object value you want to pass through the body using the PATCH method. You can specify multiple Patch operations in the JSON format. |