在Dynamics 365 Web APPI中使用FetchXML时编码/使用分页Cookie

时间:2019-07-02 17:40:01

标签: dynamics-365 dynamics-crm-webapi

我正在将FetchXML与Dynamics 365 Web API结合使用。在我尝试介绍分页之前,这很简单。

在原始查询中,我传入的是此抓取信息,我在encodeURI上进行了

<fetch nolock='true' page='1' count='5'  returntotalrecordcount='true'>
    <entity name='td_servicesummary'>
        //Query ommitted for brevity    
    </entity>
</fetch>

这将返回5个我期望的结果。总共有7个,也通过@Microsoft.Dynamics.CRM.totalrecordcount返回给我。

我通过@Microsoft.Dynamics.CRM.fetchxmlpagingcookie收到了一个分页cookie。在我看来已经被编码了:

<cookie pagenumber="2" pagingcookie="%253ccookie%2520page%253d%25221%2522%253e%253ctd_reportedon%2520last%253d%25222019-06-25T19%253a09%253a37-00%253a00%2522%2520first%253d%25222019-06-30T19%253a48%253a51-00%253a00%2522%2520%252f%253e%253ctd_servicesummaryid%2520last%253d%2522%257b62B328C1-7C97-E911-A99F-000D3AB0CA26%257d%2522%2520first%253d%2522%257bFF4A2314-709B-E911-A994-000D3AB0C24C%257d%2522%2520%252f%253e%253c%252fcookie%253e" istracking="False" />

实际上,如果我通过解码器运行该代码,则会得到更易读的版本:

<cookie pagenumber="2" pagingcookie="<cookie page="1"><td_reportedon last="2019-06-25T19:09:37-00:00" first="2019-06-30T19:48:51-00:00" /><td_servicesummaryid last="{62B328C1-7C97-E911-A99F-000D3AB0CA26}" first="{FF4A2314-709B-E911-A994-000D3AB0C24C}" /></cookie>" istracking="False" />

但是,如果我在下一个请求上设置它,则如下所示:

<fetch nolock='true' page='2' count='5' paging-cookie="<cookie pagenumber="2" pagingcookie="%253ccookie%2520page%253d%25221%2522%253e%253ctd_reportedon%2520last%253d%25222019-06-25T19%253a09%253a37-00%253a00%2522%2520first%253d%25222019-06-30T19%253a48%253a51-00%253a00%2522%2520%252f%253e%253ctd_servicesummaryid%2520last%253d%2522%257b62B328C1-7C97-E911-A99F-000D3AB0CA26%257d%2522%2520first%253d%2522%257bFF4A2314-709B-E911-A994-000D3AB0C24C%257d%2522%2520%252f%253e%253c%252fcookie%253e" istracking="False" />" returntotalrecordcount='true'>
    <entity name='td_servicesummary'>
        //Query ommitted for brevity    
    </entity>
</fetch>

我的请求返回400。

我看过一些博客,建议您无需指定页面cookie。对我来说绝对不是这样。

有人通过Web API进行获取页面的工作吗?

0 个答案:

没有答案