Reputation: 636
I am using the cakephp 3.5 to create the REST APIs. I have create an controller and method inside controller when i post the data to controller using POST MEN tools. it returning me an unexpected response
Below is the json array that i am trying use in post data
{
"type": true,
"userRole": "customer",
"signupType": "test",
"userProfile": {
"email": "[email protected]",
"password": "YLhdh3UfH/oqppQ/P4wUBw==",
"first_name": "admin",
"last_name": "admin",
"phone_no": "admin",
"profile_image": "test.jpg",
"street_address": "test address",
"state": "Chandigarh",
"city": "Chandigarh",
"zipcode": "160022",
"latitude": "30.723306",
"longitude": "76.766114",
"rating": "5",
"role": "customer",
"status": "1"
}
}
And Here is the data that i m getting inside method :-
Array
(
[{"type":"true","userRole":"customer","signupType":"gojus","userProfile":{"email":"admin@gojus_com","password":"YLhdh3UfH/oqppQ/P4wUBw] => =","first_name":"admin","last_name":"admin","phone_no":"admin","profile_image":"test.jpg","street_address":"test address","state":"Chandigarh","city":"Chandigarh","zipcode":"160022","latitude":"30.723306","longitude":"76.766114","rating":"5","role":"customer","status":"1"}}
)
This is the issues inside get data that i am getting "[{" how can i resolve the issues in cakephp 3.5
Upvotes: 0
Views: 652
Reputation: 25698
Read the Manual: XML or JSON Data
Applications employing REST often exchange data in non-URL-encoded post bodies. You can read input data in any format using Http\ServerRequest::input(). By providing a decoding function, you can receive the content in a deserialized format:
// Get JSON encoded data submitted to a PUT/POST action
$jsonData = $this->request->input('json_decode');
Upvotes: 1