cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MikeTwister
Helper I
Helper I

403 - Creating File

Hi,

 

I'm trying to do the workaround for creating folders within a library, but my Flow is failing when trying to create a .txt file. I have access rights to the Sharepoint site and subsite, but it keeps giving me a 403.

 

{
  "status"403,
  "message""Access denied. You do not have permission to perform this action or access this resource.\r\nclientRequestId: 7be4a17e-b4c5-4d8c-ab5d-6c7427031116\r\nserviceRequestId: 7c21819e-9048-6000-3104-ea71ff976c77;7c21819e-704e-6000-3104-e009dc2c9ecf;7c21819e-4054-6000-3104-e13294ba83a7",
  "source""https://XXXXX.sharepoint.com/sites/XXXXXX/XXXXX/XXXXX/XXXXX/_api/web/GetFolderByServerRelativePath(decodedUrl=@p)/files/AddUsingPath(decodedUrl=@f,%20overwrite='true')?@p='%2fsites%2fXXXXX%2fXXXXX%2fXXXXX%2fXXXXX%2fShared%2520Documents%2fEmails'&@f='Emails.txt'",
  "errors": [
    "-2147024891",
    "System.UnauthorizedAccessException"
  ]
}
 
Where XXXXX is a site/subsite respectively. I can manually create files, but the Flow still fails 😞
 
15 REPLIES 15

Can you uplaod some screenshots of your file creation action? Both in edit mode and in run mode would be useful.

editmode.PNGrun mode.PNG

 

 

 

 

Headers are here: 

Pragma
no-cache
x-ms-request-id
5a22819e-401c-6000-4899-1cce583ae7b8;5a22819e-3020-6000-4899-17d23bc62e86;5a22819e-1025-6000-4899-16666f1165cc
Strict-Transport-Security
max-age=31536000
X-Content-Type-Options
nosniff
X-Frame-Options
DENY
Timing-Allow-Origin
*
x-ms-apihub-cached-response
true
Access-Control-Allow-Origin
*
Access-Control-Expose-Headers
*
Cache-Control
no-cache
Date
Fri, 03 Aug 2018 13:27:31 GMT
Set-Cookie
ARRAffinity=901edebb081d9a6f473c817130fdc67a5853b67fcdd59faa18c8da1e3d4f4c1a;Path=/;HttpOnly;Domain=sharepointonline-ne.azconn-ne.p.azurewebsites.net
X-AspNet-Version
4.0.30319
X-Powered-By
ASP.NET
Content-Length
785
Content-Type
application/json
Expires
-1

Am I correct that you are creating a file inside a folder that doesn't exist yet?

That's correct. According to various people, it should be fine as it creates the folder then the file (in that order). I've seen multiple people achive the correct result. Any ideas?

Hi Mike,

 

Try adding a trailing '/' to the folder path in action 'Create file'. I use a '/' to start the folder path as well.

Please check if the url of the document library is correct. I need to add 2 spaces in the URL for shared documents.

 

Works on my machinecloud 😉

 

Best regards,

Erik

Hi @Erik-de-Rooij,

 

Using the fcreate file to ceate a folder isn't really right. Yes you could delete the fiel afterwards, but using the REST API would be better as it just does what it needs to do: Create the folder.

Hi @Pieter_Veenstra,

 

I totally agree that the REST API solution is the elegant one if the only thing you want to do is to create a folder. For some power users that would probably be a bit too advanced.

 

An empty folder on the other hand, to me does not really make sense. This makes me think of a few years back where file shares got really poluted by useless empty folder structures.

 

I tend to create solutions where document templates replace the dummy file and then there is no need to delete the file afterwards.

There are a few scenarios where it really makes sense to have predefined folder structures, but that is really off topic here 😉

 

Best regards,

Erik

 

A little to advanced for me indeed, I'll be trying your '/' Idea shortly as I need to recreate the flow 🙂

Thing of it from a user point of view, having a subsite created with a standard set of folders already in place is one less thing for them to do. You know what users are like when they have to do ANYTHING they don't need to do...

Unfortunately, Still getting 403 - despite it creating the folders (which I'm happy with) but error checking becomes impossible if it's always going to be erroring. I'll see if I can find another solution, or figure out the alternative API listed above 🙂

Hi Mike, did you check the '/' at the beginning and the end of the target path?

Did you also use a double space in 'Shared  Documents'? Otherwise try to create a folder in a 'test' library to rule that out first.

 

I tested it on my environment to make sure nothing was changed, and it tested out fine without any 403's.

 

Erik

I did use before and after - I'm going to be doing some tests today to figure it out - I'll let you know when and how I find out what it is 🙂

I hope you already managed to get it working.

 

If not, this is my configuration for testing it. Sorry it's in dutch. Please notice the double space in 'Shared  Documents' (red)

 

CreateFolder.PNG

 

Erik de Rooij

I'll give this a go! Thanks

Hi Mike, did you resolve this issue? I'm having the same problem.

Helpful resources

Top Solution Authors
Users online (3,620)