SharePoint Online support for # and % in file names

%3CLINGO-SUB%20id%3D%22lingo-sub-125877%22%20slang%3D%22en-US%22%3ESharePoint%20Online%20support%20for%20%23%20and%20%25%20in%20file%20names%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-125877%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20update%20a%20desktop%20app%20to%20support%20the%20use%20of%20%23%20and%20%25%20in%20file%20names%20for%20SharePoint%20Online.%20I%20have%20successfully%20modified%20some%20of%20the%20code%20to%20use%20the%20new%20CSOM%20methods%20that%20take%20a%20ResourcePath%20parameter.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20we%20also%20make%20use%20of%20the%20REST%20endpoints%20to%20access%20files%20in%20SharePoint%20and%20I%20am%20unable%20to%20find%20any%20guidance%20as%20to%20how%2Fwhen%20these%20will%20support%20the%20new%20characters.%20At%20this%20point%20we%20use%26nbsp%3BGetFileByServerRelativeUrl%20to%20determine%20if%20a%20file%20already%20exists%20in%20a%20location.%20In%20CSOM%26nbsp%3Ba%20new%20method%20(GetFileByServerRelativePath)%20has%20been%20added%2C%20but%20I%20can%20find%20no%20such%20method%20or%20documentation%20about%20how%20we%20should%20handle%20these%20characters%20in%20REST%20Urls.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20made%20especially%20difficult%20now%20that%26nbsp%3Bit's%20now%20impossible%20to%20know%20whether%20a%20Url%20containing%20%2520%20is%20an%20encoded%20space%2C%20or%20a%20%25%20followed%20by%20the%20number%2020!%20My%20understanding%20is%20that%20if%20I%20can%20get%20the%20file%20using%20CSOM%20I%20can%20know%26nbsp%3Bwhich%20it%20is%20(or%20I%20don't%20have%20to%20care)%20because%20of%20the%20new%20path%20properties%2C%20but%20if%20I'm%20trying%20to%20get%20a%20file%20by%20name%20using%20REST%20I%20cannot%20see%20any%20way%20to%26nbsp%3Bachieve%20this.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20someone%20please%20advise%20if%20I'm%20missing%20something%20or%20when%2Fif%20this%20will%20be%20possible%20using%20REST.%20I'd%20rather%20not%20move%20all%20my%20code%20to%20CSOM%26nbsp%3Bbut%20at%20this%20point%20I'm%20not%20sure%20I%20have%20much%20choice.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'd%20also%20like%20to%20know%20if%20there%20is%20a%20way%20other%20than%20accessing%20the%20tenant%20property%20SpecialCharactersStateInFileFolderNames%20(which%20I%20think%20requires%20more%20permissions%20than%20an%20average%20user%20would%20have)%20to%20know%20if%20the%20characters%20are%20supported.%20I'd%20rather%20not%20have%20to%20add%20a%20failed%26nbsp%3Bserver%20round%20trips%20just%20to%26nbsp%3Bfind%20out.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20seems%20to%20be%20a%20very%20limited%20amount%20of%20detailed%20information%20around%20these%20issues%20despite%20the%20fact%20that%20we're%20past%20the%20point%20where%20most%20tenants%20will%20have%20this%20feature%20enabled.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%20for%20any%20information%20provided!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-134921%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20support%20for%20%23%20and%20%25%20in%20file%20names%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-134921%22%20slang%3D%22en-US%22%3E%3CP%3EI%20just%20stumbled%20across%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fsolution-guidance%2Fsupporting-and-in-file-and-folder-with-the-resourcepath-api%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%3C%2FA%3Etoday.%20There%20are%20REST%20versions%20of%20the%20...Path%20methods.%20The%20date%20says%20it%20was%20early%20November%20but%20maybe%20it%26nbsp%3Bdidn't%20hit%20search%20when%20I%20was%20originally%20looking...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-127500%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20support%20for%20%23%20and%20%25%20in%20file%20names%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-127500%22%20slang%3D%22en-US%22%3EOh%20fantastic%20thanks%2C%20I%20read%20somewhere%20recently%20the%20feature%20had%20been%20released.%20I'll%20get%20onto%20our%20global%20admin%20to%20enable%20it%20as%20soon%20as%20we've%20verified%20it's%20production%20ready.%3CBR%20%2F%3E%3CBR%20%2F%3EI'd%20love%20to%20have%20a%20go%20at%20replicating%20the%20issue%3B%20once%20I%20can%20so%20I'll%20get%20back%20to%20you%20after%20some%20investigating.%20This%20is%20very%20relevant%20to%20our%20clients%20too%20as%20we%20have%20a%20lot%20of%20cloud%20migrations%20that%20we%20perform.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-127426%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20support%20for%20%23%20and%20%25%20in%20file%20names%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-127426%22%20slang%3D%22en-US%22%3EYou%20will%20only%20be%20able%20to%20if%20support%20for%20these%20characters%20is%20enabled%20in%20your%20tenant.%20See%20the%20following%20link%20for%20details%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fblogs.technet.microsoft.com%2Fwbaer%2F2017%2F04%2F06%2Fnew-support-for-and-in-sharepoint-online-and-onedrive-for-business%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fblogs.technet.microsoft.com%2Fwbaer%2F2017%2F04%2F06%2Fnew-support-for-and-in-sharepoint-online-and-onedrive-for-business%2F%3C%2FA%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-127124%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20support%20for%20%23%20and%20%25%20in%20file%20names%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-127124%22%20slang%3D%22en-US%22%3E%3CP%3ETesting%20this%20myself%20now%2C%20I%20am%20unable%20to%20upload%20any%20files%20containing%20a%20'%25'%20so%20I%20can't%20run%20through%20this%20exact%20scenario%20but%20I%20know%20that%20all%20three%20of%20those%20filenames%20you%20suggest%20are%20unique%20as%20long%20as%20they're%20encoded%20and%20then%20decoded.%20Can%20I%20ask%20where%20you%20have%20the%20ability%20to%20upload%20a%20file%20with%20a%20'%25'%20in%20the%20name%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEither%20way%2C%20if%20you%20are%20making%20a%20call%20to%20the%20endpoint%20for%20'test%252520file'%20it%20should%20absolutely%20return%20'test%2520file'%20and%20if%20that%20is%20not%20the%20case%20then%20SharePoint%20may%20not%20be%20behaving%20as%20expected.%20Maybe%20some%20double%20encoding%20might%20be%20a%20work%20around%3F%20I'm%20not%20sure%20If%20SP%20tries%20to%20parse%20any%20other%20forms%20of%20encoding%20when%20using%20the%20REST%20service.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-127061%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20support%20for%20%23%20and%20%25%20in%20file%20names%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-127061%22%20slang%3D%22en-US%22%3EThanks%20for%20your%20reply%20Charles%2C%20but%20it's%20not%20that%20simple.%20I%20have%20three%20files%20in%20a%20SharePoint%20Document%20Library%2C%20named%20%22test%25file.jpg%22%2C%20%22test%2520file.jpg%22%20and%20%22test%20file.jpg%22.%3CBR%20%2F%3E%3CBR%20%2F%3EUsing%20REST%20and%20the%20GetFileByServerRelativeUrl%20method%20the%20only%20file%20I%20can%20access%20is%20%22test%20file%22.%20If%20I%20try%20and%20access%20%22test%2520file.jpg%22%20without%20encoding%20I%20get%20the%20results%20for%20%22test%20file.jpg%22%20which%20makes%20sense.%3CBR%20%2F%3E%3CBR%20%2F%3EHowever%2C%20if%20I%20encode%20the%20%25%20(so%20using%20%22test%252520file.jpg%22)%20I%20still%20get%20the%20results%20for%20%22test%20file.jpg%22.%20No%20matter%20what%20permutation%20of%20encoding%20I%20use%2C%20I%20cannot%20access%20either%20of%20the%20files%20with%20%25%20in%20the%20name.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-125955%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20support%20for%20%23%20and%20%25%20in%20file%20names%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-125955%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20probably%20not%20of%20much%20use%20for%20the%20CSOM%20problem%20in%20reference%20to%20'%23'%20characters%20etc.%20I%20know%20it's%20a%20problem%20since%20when%20I'm%20building%20node%20projects%20from%20a%20one-drive%20folder%20it%20generates%20a%20bunch%20of%20%23%20folders%20for%20node%20modules%20and%20this%20causes%20sync%20issues%20with%20One-Drive.%20I%20heard%20from%20someone%20else%20in%20my%20team%20that%20they're%20supposedly%20adding%20'%23'%20support%20for%20file-systems%20but%20I'm%20sure%20someone%20else%20can%20verify%20when%20and%20if%20this%20is%20happening%2Fhas%20happended.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20I%20can%20say%20is%20that%20you%20can%20trust%20URL%20encoding.%20A%20filename%20with%20the%20name%20'File%2520Name'%20would%20appear%20as%20'File%252520Name'%20as%20%25%20is%20encoded%20to%20%2525.%20Just%20encode%20and%20decode%20and%20you%20should%20end%20up%20with%20something%20reliable.%20Also%20%23%20is%20encoded%20as%20%2523.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-125894%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20support%20for%20%23%20and%20%25%20in%20file%20names%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-125894%22%20slang%3D%22en-US%22%3E%3CP%3EInteresting%20question%20I%20would%20like%20also%20to%20know%20the%20answer.%20Adding%20here%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F369%22%20target%3D%22_blank%22%3E%40Vesa%20Juvonen%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I am trying to update a desktop app to support the use of # and % in file names for SharePoint Online. I have successfully modified some of the code to use the new CSOM methods that take a ResourcePath parameter.

 

However, we also make use of the REST endpoints to access files in SharePoint and I am unable to find any guidance as to how/when these will support the new characters. At this point we use GetFileByServerRelativeUrl to determine if a file already exists in a location. In CSOM a new method (GetFileByServerRelativePath) has been added, but I can find no such method or documentation about how we should handle these characters in REST Urls. 

 

This is made especially difficult now that it's now impossible to know whether a Url containing %20 is an encoded space, or a % followed by the number 20! My understanding is that if I can get the file using CSOM I can know which it is (or I don't have to care) because of the new path properties, but if I'm trying to get a file by name using REST I cannot see any way to achieve this. 

 

Can someone please advise if I'm missing something or when/if this will be possible using REST. I'd rather not move all my code to CSOM but at this point I'm not sure I have much choice.

 

I'd also like to know if there is a way other than accessing the tenant property SpecialCharactersStateInFileFolderNames (which I think requires more permissions than an average user would have) to know if the characters are supported. I'd rather not have to add a failed server round trips just to find out.

 

There seems to be a very limited amount of detailed information around these issues despite the fact that we're past the point where most tenants will have this feature enabled.

 

Thanks in advance for any information provided!

 

7 Replies
Highlighted

Interesting question I would like also to know the answer. Adding here @Vesa Juvonen

Highlighted

I'm probably not of much use for the CSOM problem in reference to '#' characters etc. I know it's a problem since when I'm building node projects from a one-drive folder it generates a bunch of # folders for node modules and this causes sync issues with One-Drive. I heard from someone else in my team that they're supposedly adding '#' support for file-systems but I'm sure someone else can verify when and if this is happening/has happended.

 

What I can say is that you can trust URL encoding. A filename with the name 'File%20Name' would appear as 'File%2520Name' as % is encoded to %25. Just encode and decode and you should end up with something reliable. Also # is encoded as %23.

Highlighted
Thanks for your reply Charles, but it's not that simple. I have three files in a SharePoint Document Library, named "test%file.jpg", "test%20file.jpg" and "test file.jpg".

Using REST and the GetFileByServerRelativeUrl method the only file I can access is "test file". If I try and access "test%20file.jpg" without encoding I get the results for "test file.jpg" which makes sense.

However, if I encode the % (so using "test%2520file.jpg") I still get the results for "test file.jpg". No matter what permutation of encoding I use, I cannot access either of the files with % in the name.
Highlighted

Testing this myself now, I am unable to upload any files containing a '%' so I can't run through this exact scenario but I know that all three of those filenames you suggest are unique as long as they're encoded and then decoded. Can I ask where you have the ability to upload a file with a '%' in the name?

 

Either way, if you are making a call to the endpoint for 'test%2520file' it should absolutely return 'test%20file' and if that is not the case then SharePoint may not be behaving as expected. Maybe some double encoding might be a work around? I'm not sure If SP tries to parse any other forms of encoding when using the REST service.

Highlighted
You will only be able to if support for these characters is enabled in your tenant. See the following link for details:

https://blogs.technet.microsoft.com/wbaer/2017/04/06/new-support-for-and-in-sharepoint-online-and-on...
Highlighted
Oh fantastic thanks, I read somewhere recently the feature had been released. I'll get onto our global admin to enable it as soon as we've verified it's production ready.

I'd love to have a go at replicating the issue; once I can so I'll get back to you after some investigating. This is very relevant to our clients too as we have a lot of cloud migrations that we perform.
Highlighted

I just stumbled across this today. There are REST versions of the ...Path methods. The date says it was early November but maybe it didn't hit search when I was originally looking...