The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

restclient request content type

mvinoth94's Avatar


07 Sep, 2015 05:17 AM

Hi ,
below is the request content type in json format.
Im using firefox RESTClient plugin to post the value.

Unfortunately i am keep on receiving the 400 Bad Request.


// POST route -to create new article
$app->post('/articles', function () use ($app) {
    try {
        // get and decode JSON request body
       // $app->request()->headers('Content-Type', 'application/json');
         $request = $app->request();
        $body = $request->getBody();
        $input = json_decode($body,true);

         // store article record
        $article = R::dispense('articles');
        $article->title = (string)$input->title;
        $article->url = (string)$input->url;
        $article->date = (string)$input->date;
        $id = R::store($article);

        // return JSON-encoded response body
        $app->response()->header('Content-Type', 'application/json');
        echo json_encode(R::exportAll($article));
    } catch (Exception $e) {
        $app->response()->header('X-Status-Reason', $e->getMessage());


RestClient plugin
name = Content-Type
value = application/json

body :

    Status Code: 400 Bad Request
    Connection: close
    Content-Length: 0
    Content-Type: text/html
    Date: Mon, 07 Sep 2015 05:14:40 GMT
    Server: Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.5.28
    X-Powered-By: PHP/5.5.28
    X-Status-Reason: Trying to get property of non-object

Where am i doing mistake

  1. Support Staff 1 Posted by Andrew Smith on 10 Sep, 2015 08:43 AM

    Andrew Smith's Avatar

    This could mean there was an issue in your Redbean's code, you will need to step through and debug to see where the issue is happening, because you are catching an Exception and returning a 400 in your code.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • restclient.png 273 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac