What is the difference between the PUT and PATCH methods in the REST API integration

Shantharao
Kilo Sage

What is the difference between the PUT and PATCH methods in the REST API integration

1 ACCEPTED SOLUTION

Anand Kumar P
Giga Patron
Giga Patron

Hi @Shantharao ,

 

PATCH

• Updates only specific fields in an existing record.

• If the record doesn’t exist, the PATCH method will fail (e.g., 404 Not Found).

• Think of it as editing just one or two pieces of information in a record.

 

Example:

If there’s an incident with Number: INC0001234 and you want to update just the Short Description field:

 

PATCH /api/now/table/incident/INC0001234  

Request Body: { "short_description": "Updated Short Description" }

 

This updates only the short description while leaving other fields, like the priority or state, unchanged.

 

PUT

• Replaces the entire record with new information.

• If the record doesn’t exist, PUT will create it.

• Think of it as rewriting all the fields of a record.

 

Example:

If there’s an incident with Number: INC0001234, and you want to completely replace it with new data:

 

PUT /api/now/table/incident/INC0001234  

Request Body: {  

  "short_description": "New Short Description",  

  "priority": "2 - High",  

  "state": "In Progress"  

}

 

This will replace all fields of the record with the new data provided. If INC0001234 doesn’t exist, it will create a new incident with this data.

 

Key Difference:

 

PATCH: Updates only the fields you specify. Example: Changing just the Short Description of an incident.

PUT: Replaces the entire record. Example: Rewriting the incident with new values for Short Description, Priority, and State.

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

View solution in original post

6 REPLIES 6

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @Shantharao 

PATCH: it is used to update an existing entity with new information. You can't patch an entity that doesn't exist. You would use this when you have a simple update to perform, e.g. changing a user's name

PUT: it is used to set an entity's information completely. PUTting is similar to POSTing, except that it will overwrite the entity if already exists or create it otherwise. You could use a PUT to write a user to your database that may already be in it.

 

 

Please refer Harsh reply in the below thread:

https://www.servicenow.com/community/developer-forum/difference-between-put-and-patch-methods-for-re...

 

Please mark the answer as helpful and correct if helped.

Kind Regards,

Ravi Chandra 

Hi Ravi,
Thank you for the quick response,
I have seen that thread already but didn't understand properly, could you please provide an example briefly in ServiceNow terminology 
Thaks in advance for your reference 

Hello @Shantharao 

 

PUT is used when we want to replace the entire resource where as Patch is used to when we want to modify specific resource.

 As Anand said, PUT will create a new record if it doesn't exist.

example for PATCH:

PATCH /api/now/table/change_request/abcdef123456

 

{

  "short_description": "Upgrade database servers - Phase 2",

  "priority": "1 - Critical"

}

 

Effect:

 

The short_description and priority fields are updated.

 

Fields like sys_id, number, state, and risk remain unchanged.

Resulting Change Request Record:

{

  "sys_id": "abcdef123456",

  "number": "CHG0001234",

  "short_description": "Upgrade database servers - Phase 2",

  "priority": "1 - Critical",

  "state": "New",

  "risk": "Low"

}

 

Please refer below videos:

The SAAS with ServiceNow is a very good resource:

https://youtube.com/playlist?list=PLzTvAeLiW8Ae4-8eJWNhzFyTqovD9LaaR&si=LDIpkPBntpSGqbDK

 

 

You can also refer below video, where she explained using postman:

https://youtu.be/HmuCXNT7YKE?si=d4aYil8WDIJA8VTM

Please mark the answer as helpful and correct if helped.

 

Kind Regards,

Ravi Chandra

For More Videos Visit: https://www.youtube.com/watch?v=m00YKjxTL6M&list=UUUNsEj27Awvb6SRQBsURZcg

Anand Kumar P
Giga Patron
Giga Patron

Hi @Shantharao ,

 

PATCH

• Updates only specific fields in an existing record.

• If the record doesn’t exist, the PATCH method will fail (e.g., 404 Not Found).

• Think of it as editing just one or two pieces of information in a record.

 

Example:

If there’s an incident with Number: INC0001234 and you want to update just the Short Description field:

 

PATCH /api/now/table/incident/INC0001234  

Request Body: { "short_description": "Updated Short Description" }

 

This updates only the short description while leaving other fields, like the priority or state, unchanged.

 

PUT

• Replaces the entire record with new information.

• If the record doesn’t exist, PUT will create it.

• Think of it as rewriting all the fields of a record.

 

Example:

If there’s an incident with Number: INC0001234, and you want to completely replace it with new data:

 

PUT /api/now/table/incident/INC0001234  

Request Body: {  

  "short_description": "New Short Description",  

  "priority": "2 - High",  

  "state": "In Progress"  

}

 

This will replace all fields of the record with the new data provided. If INC0001234 doesn’t exist, it will create a new incident with this data.

 

Key Difference:

 

PATCH: Updates only the fields you specify. Example: Changing just the Short Description of an incident.

PUT: Replaces the entire record. Example: Rewriting the incident with new values for Short Description, Priority, and State.

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand