-
-
Notifications
You must be signed in to change notification settings - Fork 220
Use X HTTP MethodOverride header for DELETE PUT
James Yang edited this page Apr 2, 2019
·
1 revision
Some Wordpress instances do not support DELETE/PUT verbs, so the suggested fallback is to use the X-HTTP-MethodOverride header and send a POST verb instead. You can use RequestFilter to achieve this. Thanks to @lxalln
private void RequestFilter(HttpWebRequest request)
{
if (request.Method == RequestMethod.DELETE || request.Method == RequestMethod.PUT)
{
request.Headers.Add("X-HTTP-Method-Override", request.Method);
request.Method = "POST";
}
}
var api = new RestAPI("http://www.yourstore.co.nz/wp-json/wc/v3/", "<WooCommerce Key>", "<WooCommerce Secret>", requestFilter: RequestFilter);