0

I am using postman to check my JSON API response from web applicaton to Mobile devices.

Here is my php code.

$checkout = new JsonSynchronization();
$checkout -> customer_id = isset($_POST['customer']) ? $_POST['customer'] : 0;
$checkout -> store_id = isset($_POST['store']) ? $_POST['store'] : 0;

$data ['customer_id']   = $checkout -> customer_id;
$data ['store_id']  = $checkout -> store_id;
echo json_encode($data);

enter image description here

I cant get the response as expected. What is the error?... can you please assist me ?

2 Answers 2

1

You are passing parameter in wrong place, Your parameter should go in Body tab. There your parameter will be as a post parameter, the place where you are currently sending is concatenation in URL, which is GET.

Sign up to request clarification or add additional context in comments.

Comments

0

You're passing the data along in the URL, so PHP sets the $_GET global, rather than the $_POST. So replace all your $_POST with $_GET. Or if you definitely want to use a POST, then make sure you enter the data as form-data when you select the POST method in postman. Currently you've got them entered as URL params.

3 Comments

but. how to send the values as post through POSTMan ?
i selected the method as POST And added params customer and store. Selected Form data in from under body tab. still no response. but I getting response fine while make php code as $_GET
I have a different version of Postman, so it all looks a little bit different on my side, but I would remove the parameters from the URL completely, and also make sure that where you enter your form-data it says Key and Value rather than URL Paramater Key and Value (like I see it says in the image you attached.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.