Skip to content

PUT requests not working? #74

Open

Description

@TheRealGuru

Hi, maybe the documentation is unclear not sure. However my put request is just not working.


    /**
     * Marks a game as completed
     *
     *
     * @url PUT /game/end
     */
    public function endGame($data) {
        print_r($data);
    }

This just won't work, the data variable contains absolutely nothing. I've tried to via a PHP curl request and a linux curl request.

PHP Request

        $data = array('test' => 'test');
        $ch = curl_init('theurl');

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));

        $response = curl_exec($ch);
        echo $response;

Linux cURL

 curl -i -H "Accept: application/json" -X PUT -d test=test url

Activity

  1. jacwright commented on Jun 22, 2016

    @jacwright
    Owner

    It appears to be a bug. While the server supports multiple formats for returning data (JSON, XML, text, etc), it only accepts JSON data for POSTs and PUTs. I suppose most people just use this server for JSON and so we haven't discovered this error until now.

    If you're going with JSON anyway you could just pass JSON data in and it would work. If you want to support application/x-www-form-urlencoded data you'll need to update the getData() method to parse the content type being sent and work accordingly. Pull requests welcome!

  2. tyzoid commented on Jul 18, 2017

    @tyzoid
    Collaborator

    The question is if it works by specifying JSON. If it does, I'd be happy to tag this as a feature-request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions