I'm using SugarCRM rest API, and according to the documentation , to get a set of records, I have to use /<module> GET
endpoint and pass JSON in the body to filter the query.
First, is it even possible to have a body in a GET request ?
and how can I build this kind of request then ?
I'm using postman and tried to pass parameters as query strings but it's not possible though.
As far as I know you have to put everything in the query string, which might look different to what you'd expect.
Example for a request to /Users
:
{
max_num: 100,
fields: ["first_name", "last_name"],
filter: [
{"user_name":"admin"}
{"status":"Active"}
]
}
Written as query string this request will look like this:
/rest/v10/Users?max_num=100&fields=first_name,last_name&filter[0][user_name]=admin&filter[1][status]=Active
Observations regarding the query string format:
{
or }
, the values of the request object are places directly in the query string =
, and separated by &
(instead of :
and ,
) "
or '
quotes at all, strings are written without those fields
) is just one assignment with all values separated by ,
filter
) has one Key-Value pair per bottom value and uses [
and ]
to indicate the "path" to each value. Using 0-based numerical indices for arrays Notes
POST /rest/v10/<module>/filter
instead. /rest/v10/Users?max_num%3D100%26fields%3Dfirst_name%2Clast_name%26filter%5B0%5D%5Buser_name%5D%3Dadmin%26filter%5B1%5D%5Bstatus%5D%3DActive
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.