You need to sign in to do that
Don't have an account?
Nitin Kumar 162
Httprequest.setMethod() not support PATCH method
There is an issue with my HTTP request.salesforce is not allowing me to use PATCH method.
Below are the notification which i get after calling a patch.
System.CalloutException: Invalid HTTP method: PATCH.
when we override the method with patch
req.setHeader('X-HTTP-Method-Override','PATCH');
req.setMethod('POST');
Then i am geeting below notification.
System.HttpResponse[Status=Method Not Allowed, StatusCode=405]
Below are the notification which i get after calling a patch.
System.CalloutException: Invalid HTTP method: PATCH.
when we override the method with patch
req.setHeader('X-HTTP-Method-Override','PATCH');
req.setMethod('POST');
Then i am geeting below notification.
System.HttpResponse[Status=Method Not Allowed, StatusCode=405]
In callouts, we don't have Patch Method in salesforce.
https://trailhead.salesforce.com/en/content/learn/modules/apex_integration_services/apex_integration_rest_callouts
In RestApi We have PATCH Method(REST Service).
https://www.youtube.com/watch?v=7PaDtgPLH90&list=PLXzeMOBB7cjcOJnkB8Am-rc_ps3661neg
https://trailhead.salesforce.com/content/learn/modules/apex_integration_services/apex_integration_webservices
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Salesforce Freelance Consultant/Developer/Administrator/Trainer
@For Salesforce Project Support: varaprasad4sfdc@gmail.com
Salesforce latest interview questions and training videos :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
All Answers
So unless you have control over the service you are calling, the only solution would be to create a custom fowarding script that you run on your own server I guess.
In callouts, we don't have Patch Method in salesforce.
https://trailhead.salesforce.com/en/content/learn/modules/apex_integration_services/apex_integration_rest_callouts
In RestApi We have PATCH Method(REST Service).
https://www.youtube.com/watch?v=7PaDtgPLH90&list=PLXzeMOBB7cjcOJnkB8Am-rc_ps3661neg
https://trailhead.salesforce.com/content/learn/modules/apex_integration_services/apex_integration_webservices
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Salesforce Freelance Consultant/Developer/Administrator/Trainer
@For Salesforce Project Support: varaprasad4sfdc@gmail.com
Salesforce latest interview questions and training videos :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
Hi NitintKumar 162,
Use req.setMethod('PUT'); and not req.setMethod('PATCH'); your code will work.
Mark this as correct answers if it works.This will help others.
Regards,
Santosh,