Open coderavels opened 2 weeks ago
This curl works
curl --location 'https://graph.microsoft.com/v1.0/drives/:driveID/items/:itemID/delta()?token=2024-06-19T20%3A19%3A17Z&%24select=id%2Cname%2CwebUrl%2ClastModifiedDateTime%2CcreatedDateTime%2CcreatedBy%2ClastModifiedBy%2Cfile%2Csize%2CparentReference%2Cdeleted%2Cshared' \
--header 'Prefer: hierarchicalsharing, deltashowremovedasdeleted, deltatraversepermissiongaps, deltashowsharingchanges'
This doesn't
curl --location 'https://graph.microsoft.com/v1.0/drives/:driveID/items/:itemID/delta(token='\''2024-06-19T20%3A19%3A17Z'\'')?%24select=id%2Cname%2CwebUrl%2ClastModifiedDateTime%2CcreatedDateTime%2CcreatedBy%2ClastModifiedBy%2Cfile%2Csize%2CparentReference%2Cdeleted%2Cshared' \
--header 'Prefer: hierarchicalsharing, deltashowremovedasdeleted, deltatraversepermissiongaps, deltashowsharingchanges'
Decided to not use the sdk DeltaWithToken
api for this use case.
Using the Delta().WithUrl(url)
instead with url that has the token query parameter injected independently of the sdk.
deltaReq, err := client.Drives().ByDriveId(driveID).Items().ByDriveItemId(itemID).Delta().ToGetRequestInformation(ctx, &drives.ItemItemsItemDeltaRequestBuilderGetRequestConfiguration{
QueryParameters: &drives.ItemItemsItemDeltaRequestBuilderGetQueryParameters{
Select: fieldsForGetDelta,
},
})
if err != nil {
return err
}
rawReq, err := client.RequestAdapter.ConvertToNativeRequest(ctx, deltaReq)
if err != nil {
return err
}
httpReq, ok := rawReq.(*http.Request)
if !ok {
return err
}
url := httpReq.URL
q := url.Query()
timestamptoken := lastUpdatedAt.Format(time.RFC3339)
q.Set("token", timestamptoken)
url.RawQuery = q.Encode()
deltaReq, err := client.Drives().ByDriveId(driveID).Items().ByDriveItemId(itemID).Delta().WithUrl(url.String()).GetAsDeltaGetResponse(ctx, &drives.ItemItemsItemDeltaRequestBuilderGetRequestConfiguration{
QueryParameters: &drives.ItemItemsItemDeltaRequestBuilderGetQueryParameters{
Select: fieldsForGetDelta,
},
})
if err != nil {
return err
}
return nil
Trying to achieve this using the sdk.
Sample Code:
But getting following error:
I have tried following values for timestamptoken other than one mentioned in sample code: