cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Guero
Level: Powered On

Creating Document Libraries through Flow with a single API call

Hi,

 

We currently have client SharePoint sites hosted on our O365 tenant, previously whenever a new client was bought on board we'd create a SharePoint site for them using the GUI or Powershell, but I'm now in the process of trying to automate site creation for any new clients that join us - Historically, all sites have been designed the same with more or less the same structure, the only difference being the files themselves. I've managed to automate the bulk of the SharePoint site creation through flow (Hub site linkage, ownership of site, group membership, external access, etc.) but I'm having trouble with creating the document libraries on newly created sites. There are 8 libraries overall, and whilst I have actually worked out how to create them each individually using the 'Send a HTTP request to SharePoint" action (I'm quite new to Flow and all this!), I'd like to try and use MS Graph and JSON batching instead, so I can create all 8 libraries in a single API call.

 

I've tested my JSON on the MS Graph Explorer, which works and and creates the libraries on a specified client site as expected, but when I try and do it through Flow, I get the below error:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Header</h2>
<hr><p>HTTP Error 400. The request has an invalid header name.</p>
</BODY></HTML>

 

Would anyone be able to tell me where I'm going wrong? I'm assuming it is the Headers, but I'm not sure what the issue is. Do I require an authorization header?

 

See HTTP action below:Doc Lib error.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Guero
Level: Powered On

Re: Creating Document Libraries through Flow with a single API call

Turns out there was never any problem with my JSON or the headers, it was simply Flow behaving strangely - I used save as and created a copy of my flow, ran it, and it worked first time? There were absolutely no differences, so I'm not sure what the issue was or how it was fixed! 

View solution in original post

3 REPLIES 3
Super User
Super User

Re: Creating Document Libraries through Flow with a single API call

Hi @Guero ,

 

I haven't personally tried but looks like you need to pass the authorisation Bearer token key to pass via http header. 

 

See the below link for more info.

https://docs.microsoft.com/en-us/graph/auth/auth-concepts

 

If you may find useful accept this as solution.

 

Thanks

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Guero
Level: Powered On

Re: Creating Document Libraries through Flow with a single API call

Hi,

 

No such luck I'm afraid - still getting the same error:

 

error2.png

 

 

Error 1.png

 

 

 

Highlighted
Guero
Level: Powered On

Re: Creating Document Libraries through Flow with a single API call

Turns out there was never any problem with my JSON or the headers, it was simply Flow behaving strangely - I used save as and created a copy of my flow, ran it, and it worked first time? There were absolutely no differences, so I'm not sure what the issue was or how it was fixed! 

View solution in original post

Helpful resources

Announcements
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (5,695)