DELETE Ajax request on a Floodlight SDN controller

Asked

Viewed 242 times

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.

Documention1

Document2

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 method OPTIONS, this is normal and the server response to "preflight" (this confirmation call) should be 200. After this "preflight" call is accepted AJAX sends the real request. In the answer you have it says Code: 405 Method Not Allowed, Are you sure this method is accepted? You have the documentation link?

  • 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)

1 answer

1

May be missing the switch, thus:

curl -X DELETE -d'{"name":"myflow1", "switch":"00:00:04:f0:21:11:3d:78"}' http://192.168.0.220:8080/wm/staticflowpusher/json
  • Using Curl you do not need to send the switch to JSON. 'DELETE -d'{"name":"flow-mod-1"}' http://10.93.15.187:8080/wm/staticflowpusher/json ' just by sending the name it already returns me as deleted: '{"status" : "Entry flow-mod-1 Deleted"}'. The documentation does not include the need to send the Switch to JSON. I think the problem is the browser that makes this confirmation call, as Sergio mentioned, and the url does not accept this OPTIONS call, so give this error. If only there was a way to bypass that pre-call...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.