The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

getParam provides null

noob's Avatar

noob

25 Aug, 2017 10:29 AM

Hi,
I'm trying to create a basic route that inserts a new tupple in the DB. For now I got:

$app->post('/test/add', function (Request $request, Response $response) {
$DB = new Db(DBHost, DBName, DBUser, DBPassword);
$id = $request->getParam('id');
$stuff = $request->getParam('stuff');

But when I enter a Json object, such as { "id":"3" , "stuff":"30" }, I get that bote $id and $stuff are null, so for some reason the getParam didn't work. I went over the syntax and definitions multiple times but couldn't find the source for it. I would appreciate your help.

Reply to this discussion

Internal reply

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

Attaching KB article:

»

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

Generic

? 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