Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUT requests not working? #74

Open
TheRealGuru opened this issue Jun 21, 2016 · 2 comments
Open

PUT requests not working? #74

TheRealGuru opened this issue Jun 21, 2016 · 2 comments
Labels

Comments

@TheRealGuru
Copy link

TheRealGuru commented Jun 21, 2016

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
@jacwright
Copy link
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!

@tyzoid
Copy link
Collaborator

tyzoid commented Jul 18, 2017

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

@tyzoid tyzoid added the On Hold label Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants