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 parameters only work in JSON format #362

Closed
Sithdown opened this issue Oct 21, 2014 · 5 comments
Closed

PUT parameters only work in JSON format #362

Sithdown opened this issue Oct 21, 2014 · 5 comments

Comments

@Sithdown
Copy link

I've been used $this->get() and $this->post() and everything works fine, but $this->put() doesn't work.

Example:

Request

PUT /api/entry/3 HTTP/1.1
Host: localhost
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryp7MA4YWxkTrZu0gW

----WebKitFormBoundaryE19zNvXGzXaLvS5C
Content-Disposition: form-data; name="demo"

Some text

Php

function entry_put() {
    $this->response($this->put('demo'),200);
}

Response

false

Expected

"Some text"

Maybe related to #354 and #252

$this->put() works fine if the PUT request is sent in json format, e.g:

PUT /projects/CI/api/log/log_id/56 HTTP/1.1
Host: localhost
X-API-KEY: 2222222222222222222222222222222222222222
Content-Type: application/json
Cache-Control: no-cache

{
"demo": "Some text"
}

Is this behaviour intended?

@Sithdown Sithdown changed the title PUT parameters don't work PUT parameters only work in JSON format Oct 21, 2014
@normeno
Copy link

normeno commented Oct 25, 2014

I have a similar problem, but it does not work even with json format. If I use $ this->get(); works perfect, but if I use $this->put (); returns me the following error: Message: Undefined property: Locals::$put

@Sithdown
Copy link
Author

@normeno commented on 25 de oct de 2014 07:58 GMT+02:00:

I have a similar problem, but it does not work even with json format. If I use $ this->get(); works perfect, but if I use $this->put (); returns me the following error: Message: Undefined property: Locals::$put

Have you added the Content-Type: application/json header? If not, the server might try parsing the request as a form and fail.

@chriskacerguis
Copy link
Owner

Hello,

Can you please send me the output of this code for your put request:

parse_str(file_get_contents("php://input"),$put_vars);
var_dump($put_vars);

@normeno
Copy link

normeno commented Oct 25, 2014

parse_str(file_get_contents("php://input"),$put_vars);
var_dump($put_vars);

return

array(0) {
}

@chriskacerguis
Copy link
Owner

Thanks for sending that.

Basically that is showing that Apache is not getting any PUT data. So, if Apache doesn't it's getting anything, then the REST-Server won't either. I would take a look at either your web server config or the client code itself.

Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants