[英]GET request with JSON body in SugarCRM
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. 我正在使用SugarCRM rest API,根据文档 ,要获取一组记录,我必须使用
/<module> GET
端点并在正文中传递JSON来过滤查询。
First, is it even possible to have a body in a GET request ? 首先,是否有可能在GET请求中包含主体?
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
: 向
/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 ,
fields
)只是一个赋值,所有值之间用分隔,
filter
) has one Key-Value pair per bottom value and uses [
and ]
to indicate the "path" to each value. filter
)的每个底值都有一个“键-值”对,并使用[
和]
指示每个值的“路径”。 Using 0-based numerical indices for arrays Notes 笔记
POST /rest/v10/<module>/filter
instead. POST /rest/v10/<module>/filter
。 /rest/v10/Users?max_num%3D100%26fields%3Dfirst_name%2Clast_name%26filter%5B0%5D%5Buser_name%5D%3Dadmin%26filter%5B1%5D%5Bstatus%5D%3DActive
/rest/v10/Users?max_num%3D100%26fields%3Dfirst_name%2Clast_name%26filter%5B0%5D%5Buser_name%5D%3Dadmin%26filter%5B1%5D%5Bstatus%5D%3DActive
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.