API $ expand& count [英] API $expand and &count
问题描述
是否可以使用$expand
,而不是返回对象的集合,而只是返回对象的数量?
Is it possible to use $expand
but instead of returning a collection of objects, just return the count of objects?
例如,在一个WebApi调用中获得一个帐户和其批注计数
For example, get an account and a count of its annotations in a single WebApi call
我尝试了一些事情.
-
明显的尝试:
accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($count=true)
返回所有注释的所有字段,但不计数任何内容.
Obvious attempt:
accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($count=true)
returns all fields of all Annotations but doesn't count anything.
接下来,我尝试accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($select=annotationid&$count=true)
返回错误:"找到了不平衡的括号表达式".我认为这与$expand
Next I tried accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($select=annotationid&$count=true)
returns an error: "Found an unbalanced bracket expression". I think this is related to the & symbol in the $expand
我找到了一个非crm博客,该博客说可以用; 解决,但是当我尝试accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($select=annotationid;$count=true)
时并没有给出错误,但是$count
指令似乎被忽略了
I found a non-crm blog that said this could be resolved with a ; but when I tried accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($select=annotationid;$count=true)
it doesn't give an error, but the $count
instruction seems to be ignored
疯狂尝试accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$count=Account_Annotation($select=annotationid)
会返回"无效计数"错误
A crazy attempt of accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$count=Account_Annotation($select=annotationid)
returns a "not a valid count" error
我猜这不是一个有效的组合,但我想我会在这里发布,以防其他人成功地实现了这一目标.
I'm guessing that this is not a valid combination, but I thought I would post here in case someone else has achieved this successfully.
推荐答案
我可以使用此功能,但是我不确定它是否正是您要查找的功能,只有在将数字放在扩展之前,它才能起作用:
I got this working, but I'm not sure it's what you are looking for exactly, it only works if I put the count before expand:
api/data/v9.0/cmnt_salesexample?
$select=endcustomeraccountid&$count=true&$expand=endcustomerid($select=accountid)
输出:
{
"@odata.context": "https://xyz",
"@odata.count": 5000,
"value": [
{
"@odata.etag": "W/\"3560581422\"",
"endcustomerid": "54321"
},
{
"@odata.etag": "W/\"3510396844\"",
"endcustomerid": "12345"
},
...
这篇关于API $ expand& count的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!