[英]Consecutive Rest request doesn't bring updated data
Working with the ZenDesk Rest API (some ticket management software), I have the functionalities of listing tickets and creating new ones. 使用ZenDesk Rest API (一些票务管理软件),我可以列出票证并创建新票证。
Here's the scenario: 这是场景:
On step one, say 20 tickets are returned. 在第一步中,说返回20张票。 On step 3, the same 20 tickets are returned.
在步骤3中,将返回相同的20张票证。 After a while though, the request brings the 21 expected tickets.
过了一会儿,请求带来了21张预期的门票。
Here's some code: 这是一些代码:
public JObject GetTicketsByUserEmail(string userEmail)
{
var client = new RestClient(RequestUri);
client.Authenticator = new HttpBasicAuthenticator(Username, Password);
string resource = "/api/v2/search.json?query=type:ticket tags:" + userEmail;
var request = new RestRequest(resource, Method.GET);
client.AddDefaultHeader("Accept", "application/json");
request.Parameters.Clear();
request.RequestFormat = DataFormat.Json;
IRestResponse response = client.Execute(request);
var content = response.Content;
client.Execute(request);
JObject jObject = JObject.Parse(content);
return jObject;
}
The above works fine, bringing the tickets as expected. 上面的工作正常,带来了预期的门票。 After creating a new one, I can see on ZenDesk's web application the newly created ticket.
创建新票证后,我可以在ZenDesk的Web应用程序上看到新创建的票证。
The above code is then run again but it doesn't bring the new ticket to the .Net code, despite existing on the ZenDesk portal! 上面的代码然后再次运行,但是尽管ZenDesk门户网站上已有它,也不会将新票证带到.Net代码! So the list that is shown to the user is refreshed but doesn't show him the ticket he just created.
因此,显示给用户的列表会刷新,但不会显示给他刚创建的票证。
Well, since I can see the new ticket on the ZenDesk portal, I'm guessing the Rest request on the .Net side is somehow not refreshing or using old data, I don't know. 好吧,因为我可以在ZenDesk门户上看到新的票证,所以我猜.Net端的Rest请求在某种程度上不刷新或使用旧数据,我不知道。
I need to return the new updated data with newly created records in it. 我需要返回包含新创建记录的新更新数据。
Their support team provided the answer to this. 他们的支持团队提供了答案。
Since I'm retrieving my tickets using their Search
method instead of the Tickets
one (because I want to filter my results), the results retrieved aren't immediately updated, as they alert in their documentation : 由于我是使用票务的
Search
方法而不是Tickets
方法来获取Tickets
(因为我想过滤我的结果),因此检索到的结果不会立即更新,因为它们会在其文档中发出警报:
Note: It can take up to a few minutes for new tickets, users, and other resources to be indexed for search.
注意:新的票证,用户和其他资源可能需要花费几分钟才能被索引以进行搜索。 If new resources don't appear in your search results, wait a few minutes and try again.
如果新资源未出现在搜索结果中,请等待几分钟,然后重试。
So, after creating a new ticket, it is actually created but not immediately indexed for search, which means a Search
call that is made right after a ticket creation won't contemplate that new record. 因此,在创建新票证之后,实际上会创建该票证,但不会立即为其索引以进行搜索,这意味着在创建票证后立即进行的
Search
调用不会考虑该新记录。
The time that takes to index the new records isn't fixed or possibly calculated. 索引新记录所需的时间是固定的,也可能无法计算。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.