support for DELETE and PUT verb via POST

12 views
Skip to first unread message

vaibhav

unread,
May 18, 2011, 12:31:35 AM5/18/11
to mis...@googlegroups.com
my app is in webos environment and like some browsers it doesn't support PUT or DELETE request, is there a workaround available using POST instead  like GDATA API or emulated by rails. specifically DELETE request is not available and will be changed to PUT.

Nathan Esquenazi

unread,
May 18, 2011, 12:33:24 AM5/18/11
to mis...@googlegroups.com
The approach used by Rails should work, utilizing a POST with a "_method" parameter with the value as the method. Try that and let us know if you run into any problems.

-- 
Nathan Esquenazi
Lead Platform Engineer
Miso (gomiso.com)

vaibhav mishra

unread,
May 19, 2011, 12:36:17 AM5/19/11
to mis...@googlegroups.com
I poster a reply yeterday but somehow it got lost or something, here is the problem, it is not working, here is my request


this.method = 'POST';
    var url = 'http://gomiso.com/api/oauth/v1/media/favorites.json';
    this.request_parameters = 'media_id='+this.media.id;
    this.request_parameters = this.request_parameters+'&_method=delete';
    this.signHeader(this.request_parameters, url);
    var xhr = new XMLHttpRequest();
    xhr.open("POST", url, true);
    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xhr.setRequestHeader('Authorization', this.authHeader)
    xhr.onreadystatechange = function(evt){
        if (xhr.readyState == 4) {
            if ((''+xhr.status).indexOf('200')>=0) {
                   //code
            }
            else {
            }
        }
    }
.bind(this);
xhr.send(this.request_parameters);

Nathan Esquenazi

unread,
May 19, 2011, 8:16:41 PM5/19/11
to misoapi
That is too bad, I feel we may have to investigate this, I can
understand that sending a POST with the _method parameter should act
the same way as a normal PUT or DELETE. I guess for some reason this
is currently not working. We will check this out and get back to you.
Reply all
Reply to author
Forward
0 new messages