2
I have a function in my Javascript that makes an Ajax request to the REST interface of a Floodlight controller.
function excluir(nome)
{
var jsonExclui = ("{" + '"name": "'+nome+'" }');
alert(jsonExclui);
$.ajax(
{
url: "http://192.168.56.99:8085/wm/staticflowpusher/json",
method: "DELETE",
// type: 'DELETE',
data: jsonExclui,
dataType: "json",
success: function(data)
{
alert(data.status);
},
error: function(data)
{
alert("Deu erro : "+data.status);
}
});
}
The DELETE method is accepted and included in the SDN driver documentation.
But when analyzing the browser console I realized that it tells me that I am sending OPTIONS and not DELETE.
Accept-Ranges:bytes Allow:DELETE, POST Connection:Keep-Alive Content-Type:application/json Date:Thu, 14 May 2015 11:46:43 GMT Server:Restlet-Framework/2.3.1 Transfer-Encoding:chunked Remote Address:192.168.56.99:8085 Request URL:http://192.168.56.99:8085/wm/staticflowpusher/json Request Method:OPTIONS Status Code:405 Method Not Allowed
This is common?
Standard AJAX requests are
GET, HEAD or POST. Everyone else makes the browser make a config call before sending the real order. This confirmation call has methodOPTIONS, this is normal and the server response to "preflight" (this confirmation call) should be200. After this "preflight" call is accepted AJAX sends the real request. In the answer you have it saysCode: 405 Method Not Allowed, Are you sure this method is accepted? You have the documentation link?– Sergio
When I request the browser tells me that for that url (http://192.168.56.99:8085/wm/staticflowpusher/json) POST and DELETE methods are allowed, OPTIONS is not. Documentation:(https:/floodlight.atlassian.net/wiki/pages/viewpage.action?pageId=1343518) (https://floodlight.atlassian.net/wiki/display/floodlightcontroller/Floodlight+REST+API)
– DaviAragao