Ulterior
Ulterior

Reputation: 2892

Cant retrieve laravel post data with json

I cant retrieve json post data using fiddler

POST http://localhost/backend/login HTTP/1.1
User-Agent: Fiddler
Host: 192.168.0.147
content-type: application/json
Content-Length: 278

{
    'name': 'Phill Sparks',
    'location': 'England',
    'skills': [
        'PHP',
        'MySQL',
        'Laravel'
    ],
    'jobs': [
        {
            'org': 'Laravel',
            'role': 'Quality Team',
            'since': 2012
        }
    ]
}

routes:

Route::post('backend/login', 'UserController@backendLogin');

controller:

public function backendLogin()
{
//Input::all() and Input::json()->all() are empty
}

anything missing here?

Upvotes: 0

Views: 224

Answers (1)

lowerends
lowerends

Reputation: 5267

You need to replace you single quotes ('England') with double quotes ("England") to have a valid JSON payload. You need to do this for both the keys and the values.

Upvotes: 1

Related Questions