How to avoid the 405 error { "message": "Method not allowed" } in Rest Message in Put method

sowmyab
Giga Contributor

Hi all,

How to avoid the   405 error { "message": "Method not allowed" } Rest Message in Put method?

Written same thing in POST method   that is working fine but for put method getting 405 error.

If any one the solution please let us know.

Regards,

9 REPLIES 9

as khozemaattar has already suggested you to use "Patch" instead of "Put" .



When using PUT, it is assumed that you are sending the complete entity, and that complete entity replaces any existing entity at that URI. In the above example, the PUT and PATCH accomplish the same goal: they both change this user's email address. But PUT handles it by replacing the entire entity, while PATCH only updates the fields that were supplied, leaving the others alone.



json - REST API - PUT vs PATCH with real life examples - Stack Overflow


Hi Harsh,



Yep -   in general REST sense Put and Patch are not quite the same.



The ServiceNow implementation of   REST Table api treats them the same however


ServiceNow KB: Table API FAQs (KB0534905)


..


11. What is the difference between PUT and PATCH?


In the REST world, PUT and PATCH have different semantics. PUT means replace the entire resource with given data (so null out fields if they are not provided in the request), while PATCH means replace only specified fields.   For the Table API, however, PUT and PATCH mean the same thing.   PUT and PATCH modify only the fields specified in the request.


tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Sowmyab,



I think you are trying to do something via the REST api that you could not do via the GUI.


It is not expected that an incident number can be changed after creation.



The end point should look like this


PATCH https://instance_name.service-now.com/api/now/table/incident/965c9e5347c12200e0ef563dbb9a715


and the   Request Body like this



{"short_description":"test"}

If the reply was informational, please like, mark as helpful or mark as correct!


I tried without number and content also , still facing same issue.


Khozema Attar1
Tera Guru

Hi,



You generally get this error when method is known by server but has been disabled and cannot be used.



Refer the following links : 405 Method Not Allowed - HTTP | MDN


java - HTTP Status 405 - Method Not Allowed Error for Rest API - Stack Overflow



If you are using the PUT method , it is possible that the method has been disabled by the third party.



You can try using PATCH method in REST Api to update something.



Thanks