How do I enable PUT requests in Azure?
Add the following to the web.config
in the system.webServer
element:
<handlers>
<remove name="PHP54_via_FastCGI" />
<add name="PHP54_via_FastCGI" path="*.php" verb="GET, PUT, POST, HEAD, OPTIONS, TRACE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK" modules="FastCgiModule" scriptProcessor="D:\Program Files (x86)\PHP\v5.4\php-cgi.exe" resourceType="Either" requireAccess="Script" />
</handlers>
This works for the built in versions of PHP, the current default is PHP 5.4, but if you have selected PHP 5.3 or PHP 5.5 you will need to modify the path of the php-cgi handler.
python requests: PUT request to azure fails with 415 error
The HTTP header should Content-Type
and not contentType
.
headers = {
"dataType": "json",
"accept":"application/json",
"Content-Type":"application/json",
"Authorization": "Bearer " + bearer_token }
Also, parameter data
should be JSON encoded.
r = requests.put(url, json=data, headers=headers)
PUT request to Azure storage with shared key authorization
Besides Content-Type
, for a put request, you also need to fill Content-Length
in string_params as corresponding header is probably set by sdk automatically.
Angular Put request not working with Laravel 5.3 hosted on azure
So, Because Apache and IIS servers are different. IIS does not handle PUT and DELETE by default. It also handles params for PUT request differently.
Instead of body, you need to send it in a query string like ../resource?param1=value1
. AKA x-www-form-urlencoded
This article explains it thoroughly
As of angular, this worked for me.
function (id, params) {
params.api_token = TOKEN;
var params = $httpParamSerializerJQLike(params);
return $http.put(url+'/lead/'+id+'?'+params);
}
NOTE: In addition, your web.config
does require <handler>
tags to be able to handle these requests. which is defined here
Are PUT and DELETE requests supported by Azure Static web apps CLI on local environment?
Turns out the solution is adding a staticwebapp.config.json file (sample allowing any user to run PUT and DELETE calls, even when not authenticated):
{
"routes": [
{
"route": "/api/*",
"methods": ["GET", "POST", "PUT", "DELETE"]
}
]
}
Related Topics
How to Convert PHP Regex to JavaScript Regex
File Download Script Doesn't Work When Called from Ajax
Submit Multiple Forms with One Button
Increase the Limit of File Upload Size in Heroku While Uploading to Dropbox
How to Increase My "Advanced" Knowledge of PHP Further? (Quickly)
Starting with Laravel on Ubuntu
Loop Through All Months in a Date Range
How to Increment Count in the Replacement String When Using Preg_Replace
PHP Dynamic Name for Object Property
Uploading a File via Ajax with PHP
How to Parse Fixed Width Column Text in PHP
How to Detect Fake Users ( Crawlers ) and Curl
How to Make Short Random Unique Keys, Like Youtube Video Ids, in PHP