cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

Rename Folder by HTTP request - SPLIT email subject as new name

I have searched high and low for a solution to this, tried it feels like everything...

My flow:

Project Folder Create.PNG

 

The Compose action takes the prefix "ANewProjectFolder " off the start of the email subject, leaving the name of the new project. Example subject: "ANewProjectFolder PROJECT1 - 12345"

 

The HTTP request is designed to rename the template folder to the project name.

This functions correctly if I edit the trigger email and remove the prefix, remove the Compose and use the whole email Subject as the argument. The trouble is that email is generated automatically from our CRM, and I don't have access to change the subject content.

 

When I use the 'Outputs' of the Compose, it complains of a missing comma in the JSON of the body of the HTTP request. I know it's in the body because everything else works when I remove the Compose as above.

 

Does anyone see the error where there should be a comma, or is there a missing (or extra) ' somewhere?

Thanks so much.

 

N.B. I choose to use rename rather than create a new folder, because the subfolder structure for a project (plus a few batch files which bring in the latest versions of templates at time of use, soon to be replaced with Flows) is within the template project folder "_MasterProject". 

 

Thanks again.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Advocate II
Advocate II

Re: Rename Folder by HTTP request - SPLIT email subject as new name

Just to update, I found a different solution:

Copy the template file

Get metadata

Get File Properties

Get File Content

Create New File using Content

If fails, delete template

PARALLEL TO LAST STEP: Delete original copied template

 

I didn't expect it to work for DWG files, could've saved myself a few days of non-stop Google if I'd just tried it...

View solution in original post

5 REPLIES 5
Highlighted
Resolver IV
Resolver IV

Re: Rename Folder by HTTP request - SPLIT email subject as new name

Hi @james_goodhew 

 

It looks like there is an issue with the JSON you are trying to pass

 

It appears that a comma is missing at the end of the first output on the Title line

 

I also believe you need to use Double quotes in the JSON instead of single quotes

 

Also when you run the flow do you get the results you expecting in the compose action?

 

 

Highlighted
Advocate II
Advocate II

Re: Rename Folder by HTTP request - SPLIT email subject as new name

Hello, and thank you!

I added the comma, I did try it with and without, screenshot shows without.

No dice.

 

The output of the Compose works as expected, the output looks great when I successfully ran it as a test without splitting the email subject.

 

Ref double quotes within the JSON, I suspected something like that, because there are so many single quotes it's probably interpreting the end of a part of the JSON as the end of a property, and expecting a comma. I don't know how to add the double-quote in, because it's within the output of a Compose action - can you help me out a little more? Maybe I can take the output of a test run, copy and paste it into the Body of the HTTP request and add double quotes? And by double quotes, do you mean SHIFT+2 on a UK keyboard, or 2 apostrophe characters next to each other?

 

This is the output of a test on the HTTP request.

I imagine it wants double quotes around "Subject" and "ANewProjectFolder "?

{
'Title': 'last(split(triggerBody()?['Subject'],'ANewProjectFolder '))',
'FileLeafRef': 'last(split(triggerBody()?['Subject'],'ANewProjectFolder '))'
}

 

I'm getting bad gateways now for everything - I guess I'll have to wait a bit before trying again...

Highlighted
Resolver IV
Resolver IV

Re: Rename Folder by HTTP request - SPLIT email subject as new name

You can try and set it up like below which should work 

 

Based on the screenshot are you using an expression in the Input field, if you when you run the flow you should see the name of the project in the Output.

 

Expressions use single quotes, however when preparing json you will need to wrap the field names in double quotes

 

 

 

Screen Shot 2020-01-13 at 8.01.47 pm.png

 

The JSON should look like below

{
"Title":@{outputs('Compose')},
"FileLeafRef": @{outputs('Compose')}
}

 

On the UK keyboard it should be shift+2

 

Hopefully this helps

Highlighted
Advocate II
Advocate II

Re: Rename Folder by HTTP request - SPLIT email subject as new name

Hello again,

 

Thanks so much, but copying and pasting this into Body generates a new JSON error:

"Invalid JSON. A token was not recognized in the JSON content."
 
Or, if I wrap Output in apostrophes as before, with Title and FileLeafRef in double quotes, it complains of missing a comma again.
Highlighted
Advocate II
Advocate II

Re: Rename Folder by HTTP request - SPLIT email subject as new name

Just to update, I found a different solution:

Copy the template file

Get metadata

Get File Properties

Get File Content

Create New File using Content

If fails, delete template

PARALLEL TO LAST STEP: Delete original copied template

 

I didn't expect it to work for DWG files, could've saved myself a few days of non-stop Google if I'd just tried it...

View solution in original post

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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!

Users online (7,907)