Support the ongoing development of Laravel.io →
posted 9 years ago
Requests Input
Last updated 2 years ago.
0

If php / pdo can lumen can. Lumen is a php framework.
http://stackoverflow.com/questions/18354638/json-post-and-decode-array-to-php

Last updated 9 years ago.
0

If the json is not formatted correctly it will just silently fail to parse it

0

Thanks for the replies! I got it working now.

The answer I was looking for was to use the Request::json()->get method, to extract the JSON data from the request.

So, posting a request like this...

POST / HTTP/1.1
Host: localhost
Content-Type: application/json

{
    "name": "dave"
}

...and accessing the data using something like...

$app->post('/', function() use ($app) {
    dd(Request::json()->get('name'));
});

Maybe useful for someone else. Thanks!

Last updated 9 years ago.
0

I wrote about this topic - "How to Submit a JSON POST Request in Lumen" - https://medium.com/@paulredmond/how-to-submit-json-post-requests-to-lumen-666257fe8280

0

Sign in to participate in this thread!

Eventy

Your banner here too?

gaz gaz Joined 17 May 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.