4

I'm trying to read content of a file as stream in document library on sharepoint online site. I'm using AppOnlyAccessToken. Source code work fine before today. And I have no idea for this problem. My source code:

string realm = TokenHelper.GetRealmFromTargetUrl(SiteUrl);
var token = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, SiteUrl.Authority, realm);

var context = TokenHelper.GetClientContextWithAccessToken(SiteUrl.ToString(), token.AccessToken);

//Initial
Stream stream = null;

var list = context.Web.GetList("/sites/mysites/mydoclib");

var document = list.GetItemById(fileId);
context.Load(document.File);
context.ExecuteQuery();

////Read File and return stream content of file
var streamX = document.File.OpenBinaryStream();

context.ExecuteQuery();
stream = streamX.Value;
return stream;

Error when ExecuteQuery() to get BinaryStream. Error Message:

The label that's applied to this item prevents it from being edited or deleted. Check the item's label for more details.

It work with txt file and get error with csv and excel (xlsx) file.

icebat
  • 4,696
  • 4
  • 22
  • 36
  • 1
    I got the same error in my app which was working fine till last week. I am currently circumventing it by keeping the file locally in the app folder. Not really a good solution. – Abdul Hameed Nov 09 '17 at 05:10
  • Same problem here.. It started few days ago too.. It was working normally. Nuget downgrade doesn't help. SharePoint Online too. I think it has to be something with: Updated feature: New buttons available in SharePoint Online list and library web parts MC124446 Published On : November 7, 2017 – Circus Ranger Nov 09 '17 at 08:12
  • My organisation has raised a support ticket with Microsoft and I have provided them with a Fiddler trace of the error containing a TraceCorrelationId. It looks like this is only happening on certain tenancies and not others. I would recommend that all of you also raise support tickets about this if you can. The more attention we can get to this issue, the better (and it will also be helpful for them to know which tenancies are affected). – JLRishe Nov 09 '17 at 18:37
  • Same problem here, started few days ago. Using SDK / CSOM or REST - same error. It works on other tenants though. Our tenant have configured protection.office.com Labels in April. Documents does not have any label applied. We try to just retrieve document, not to delete/modify it. – Hrvoje Kusulja Nov 09 '17 at 23:25
  • Same problem with our tenants (starting November 3rd) First we speculated it to be with specific file types, then it started happening with all file types. Looks like they are not allowing access to file content and the error message is totally misleading. We are also noticing it for the API calls for permissions of a document (using the OneDrive API) – Syed Mauze Rehan Nov 11 '17 at 15:47
  • I've made [a post to TechNet](https://social.msdn.microsoft.com/Forums/office/en-US/dc31f709-8783-4428-9bc8-0e6afb6b5287/) describing the issue and an MS employee has responded saying that they were able to reproduce the issue. They suggested that I make a post on Office 365 UserVoice which I have done here: https://office365.uservoice.com/forums/264636-general/suggestions/32235430 – JLRishe Nov 13 '17 at 11:25
  • Do you have enabled Azure Active Directory - Conditional Access for SharePoint ? If so, can you please share details. It seems it is easy to reproduce on a new tenant if you create those. However, I have disabled all of them temporary, and still same issue. Also, I do have O365 support ticket, and they are still analyzing the issue. – Hrvoje Kusulja Nov 17 '17 at 00:56

2 Answers2

2

The issue is resolved with recreating (revert to full access and then adjust what you need) SharePoint Online Access Policies for Azure Active Directory - Conditional Access.

Ref: https://TENANT-admin.sharepoint.com/_layouts/15/online/TenantAccessPolicies.aspx https://portal.azure.com/#blade/Microsoft_AAD_IAM/ConditionalAccessBlade/Policies

Error message is wrong and it does not have nothing with labels on https://protection.office.com

Hrvoje Kusulja
  • 925
  • 1
  • 11
  • 25
1

While I don't have any of the technical details of what happened, this was an issue that Microsoft caused in some update and after several weeks of back and forth with them in a support ticket, they have made another change in the last 24 hours that has fixed the issue in my customer's tenant.

If you are still experiencing the same issue, you should file an O365 support ticket and reference my customer's ticket number (SRX617110692037176ID) saying that you are experiencing the same issue as them. Hopefully that should speed the process along for you.

I am trying to obtain a bit more detail from Microsoft about what exactly happened and what they fixed, and will add it here if I obtain any more information.

It looks like a MS Senior Program Manager has added an answer below that has been deleted, but I think this information is worth knowing, so I am quoting it here:

There is a fix that should be out in couple of weeks which will let the APPONLY calls go through even if the policy is on

JLRishe
  • 99,490
  • 19
  • 131
  • 169