cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ShaneC
New Member

Save email attachments to SharePoint online

I created a basic flow that saves email attachments from O365 to SharePoint online.

 

  • Each morning at 5:30am I get about 37 email messages sent from various systems to this mailbox.
  • The same flow is used to save the attachments into a specific SharePoint folder and takes about 6 seconds to run on average.
  • About half of the attachments are saved, but then other half fails.
  • The error I get is Unauthorized - "Invalid JWT token. The token is expired."

As mentioned, I use the same flow. If I retry the failed flow, it runs through successfully.

 

Could there be an error that too many connections are trying to save to the same SharePoint site at the same time? The fact that the flow succeeds with a retry tells me that there is nothing wrong with the flow, but rather the systems it connects too (i.e. SharePoint) that is rejecting the request?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Hi Michael,

 

That did not resolve the problem. The same flow is used for other emails and some of them do work. Your approach would be correct if none of my flows was working.

 

I managed to resolve this issue by adding a Delay with a random value between 10 & 60 seconds (rand(10,60)) before saving the attachment to SharePoint. I suspected that SharePoint is throwing an error when too many flows is trying to write to the same library at the same time.

 

As mentioned, I have internal systems email reports at the exact same time (5:30am). There is over 37 reports. After introducing the delay, the writes to SharePoint is staggered over a 60 second period.

 

All my flows successeded this morning.

 

Thanks anyway for taking the time to review.

 

Regards

Shane

View solution in original post

2 REPLIES 2
v-micsh-msft
Community Support
Community Support

Hi  @ShaneC,

 

Please take a try to refresh your Authentication information for the SharePoint connection used in this Flow.

A thread talking about the same issue:

"Invalid JWT Token. Could not resolve issuer token" when attempting to create simple flow on SP List

 

If it won't help, then please share the failed Flow Running details page URL, which should contain Flow ID and the Run ID:

For example, the following URL:

{

https://asia.flow.microsoft.com/manage/environments/Default-9e51064f-f6a5-41a2-89a9-9785a9d6c706/

flows/38ca79fc-a949-4c55-8d22-35c2261d0fb1/

runs/08586998674477287234292968369

?backUrl=%2Fflows%2F38ca79fc-a949-4c55-8d22-35c2261d0fb1%2Fdetails

&runStatus=Succeeded

}

The error message should mean the token used to connect to SharePoint is expired. A simple refresh ( in Flow I think it should be things like to Start a new run) would make it work.

For detailed scenario, it would need to take a look at the corresponding Flow running information to check out.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Michael,

 

That did not resolve the problem. The same flow is used for other emails and some of them do work. Your approach would be correct if none of my flows was working.

 

I managed to resolve this issue by adding a Delay with a random value between 10 & 60 seconds (rand(10,60)) before saving the attachment to SharePoint. I suspected that SharePoint is throwing an error when too many flows is trying to write to the same library at the same time.

 

As mentioned, I have internal systems email reports at the exact same time (5:30am). There is over 37 reports. After introducing the delay, the writes to SharePoint is staggered over a 60 second period.

 

All my flows successeded this morning.

 

Thanks anyway for taking the time to review.

 

Regards

Shane

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,512)