on
getParsedBody() 와 getBody() + Postman에서 test
getParsedBody() 와 getBody() + Postman에서 test
There are two types which you can bring the data from the body in PHP.
1. getParsedBody()
: return as an array type
2.getBody()
: return as an object type, json
When using getParsedBody(), you need to choose ' x-www-form-urlccoded' on Postman.
On the other hasd, for getBody(), you need to choose raw -> json on Postman.
For example, you gonna bring these data from the body.
{
"contacts": {
"emails": [
]
}
}
- for getParsedBody() & x-www-form-urlcoded
=> contacts is an array having email and phone number
=> At the same time, email could be more than two, so it has to be an array type as well.
=> key has to be contacts[] for one array, contacts[email][] for two
- for getBody() & raw->json
=> just put the data as json .
from http://kkokkoma-dev.tistory.com/189 by ccl(A) rewrite - 2021-12-14 16:01:12