cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mishatandon
Helper III
Helper III

Error : "message": "Invalid type. Expected Object but got Array.",

Hi community,

 

I am trying to build a flow which upload the attachment along with other values submitted on MS forms to Sharepoint.

 

I am referring to post @yashag2255  at below link but getting Json Parse error:

 

"message""Invalid type. Expected Object but got Array.",
    "lineNumber"0,
    "linePosition"0,
 
What am i doing wrong?
 
Attached the flow screenshot
 
JSON:
 
{ "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "link": { "type": "string" }, "id": { "type": "string" }, "type": {}, "size": { "type": "integer" }, "referenceId": { "type": "string" }, "driveId": { "type": "string" }, "status": { "type": "integer" }, "uploadSessionUrl": {} }, "required": [ "name", "link", "id", "type", "size", "referenceId", "driveId", "status", "uploadSessionUrl" ] } }
Attachment flow.png

 

 

 

https://www.bythedevs.com/post/working-with-files-on-ms-forms-in-ms-power-automate

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Mishatandon ,

 

You have to set Input of Apply To each loop as Body from Parse Json. Remove another apply to each loop. Just add Get file content and use Id from Parse JSON.

 

Thanks

View solution in original post

9 REPLIES 9
ManishJain
Solution Sage
Solution Sage

Hi @Mishatandon ,

 

The JSON you are referring here should be used as Schema as it is . Do not use generate from sample and provide this json.

 

Thanks

@ManishJain  thanks that worked but gave error on the subsequent step.

 

Unable to process template language expressions for action 'Apply_to_each' at line '1' and column '2857': 'The template language expression 'body('Parse_JSON')?['items']?['properties']?['id']' cannot be evaluated because property 'items' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.

Hi @Mishatandon ,

 

In Apply to each loop you should select Items as this is array. Then inside the loop for getting file content you should be using 

items('Apply_to_each')?['id']

 

Thanks

Further made changes and getting error:

 

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each_2')['id']' is of type 'String'. The result must be a valid array.

 

 

Made the changes as per suggestion but getting error.

 

Screenshot:

 

Attachment flow 2.png

Hi @Mishatandon ,

 

You have to set Input of Apply To each loop as Body from Parse Json. Remove another apply to each loop. Just add Get file content and use Id from Parse JSON.

 

Thanks

View solution in original post

Worked fine, thanks @ManishJain !

 

Would this work for multiple attachments uploaded on MS forms?

Hi @Mishatandon ,

 

Yes it should work for more than one as it is array.

 

 

Thanks

Hello @ManishJain 

 

I am using the process in this blog to create my own flow : https://techcommunity.microsoft.com/t5/microsoft-teams-blog/building-low-code-no-code-approval-workf...

 

I am creating 2 flows, where first flow creates a message card

Flow 1.jpg

 

And then when the user approves or rejects the other card, the second flow gets activated.

 

json2.jpg

But I am getting this error in the Parse JSON 2:

error2.jpg

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

Top Kudoed Authors
Users online (2,942)