RESTful through free web host (PUT, DELETE)

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by mgorgeix, Mar 25, 2015.

  1. mgorgeix

    mgorgeix New Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Just want to start by saying that I have researched this subject for a while now--through trying methods on Stackoverflow.com and using searches on this forum to see if someone else has addressed this question.

    Is it possible to use the verbs PUT or DELETE? I understand if it is not allowed by the host, but I haven't found a thread that explicitly says that they are not allowed or that someone was successful or unsuccessful using them. I either get a 404 or 405 error when trying to use these on x10host.com. I have modified .htaccess and the target's headers to no avail.
     
  2. leafypiggy

    leafypiggy Manager of Pens and Office Supplies Staff Member

    Messages:
    3,819
    Likes Received:
    163
    Trophy Points:
    63
    PUT and DELETE are HTTP verbs that are understood by the webserver... what I would believe is happening is that your application doesn't understand the requests. What is an example URL that is causing this behavior?
     
  3. mgorgeix

    mgorgeix New Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Okay I sort of misspoke and maybe I'm wrong altogether. _SERVER["QUERY_STRING"] comes up as null everytime I send POST, DELETE, or PUT. I have no problems with a GET request.

    http://mgorgei.x10host.com/test/

    Pressing Add will send POST, Delete with a <tr> highlighted will send DELETE. Right now, the php page receiving the request is taking GET only and passing phpinfo(32); if it sees anything else. This is just demonstrating _SERVER["QUERY_STRING"] coming empty, I obviously wouldn't leave it this way if it worked.
     
  4. essellar

    essellar Community Advocate Community Support

    Messages:
    3,295
    Likes Received:
    227
    Trophy Points:
    63
    Why are you using QUERY_STRING with PUT?
     
  5. mgorgeix

    mgorgeix New Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I'm not even sure.

    You have to pass data somehow otherwise I just don't see the reason behind request methods. Shouldn't you specify what resources you're changing with PUT, what you're deleting with DELETE, etc.? If not through QUERY_STRING, then what? It would seem logical to me if GET would pass a value through QUERY_STRING, then why not the other request methods.
     
  6. AngusThermopyle

    AngusThermopyle Active Member

    Messages:
    319
    Likes Received:
    52
    Trophy Points:
    28
    Look up how POSTs are handled. The data is in the body of the request, not in a query string attached to the URL.

    PUTs should be handled similarly.

    Any request that changes data should never use query-strings. (Think of the URL being saved in browser History or Bookmarks. And then called again. The request is repeated. Is that what you really want? PUT the same deposit/purchase twice?)
     
  7. mgorgeix

    mgorgeix New Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1

Share This Page