I use this code to retrieve files from a OneDrive folder. It works perfectly, except for the fact that changes take a long time to propagate. For example if I delete a file, the response will continue to return that file for some 10 minutes. What am I doing wrong?
string endpoint = "https://graph.microsoft.com/v1.0/users/{UserId}/drive/root/search(q='.txt')?$select=Id,SharepointIds,WebUrl,Name,Size,FileSystemInfo,CreatedBy,LastModifiedBy";
var httpClient = new HttpClient {
BaseAddress = new Uri(endpoint)
};
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
using (var response = await httpClient.GetAsync(endpoint)) {
string json = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<ResponseModel>(json, options);
}
While I can reproduce this issue in Postman, Graph Explorer syncs within a few seconds. I have since discovered that the syncing issue resolves itself if I use Graph Explorer's access token.
Here is the endpoint I am using. I guess all I really need to know is how Graph Explorer generates its access token (or synchronization token?) in this situation.
string endpoint = https://login.microsoftonline.com/{TenantId}/oauth2/v2.0/token