cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Issues with array form item

Hello,

 

I have an XLSForm hosted on premises. Using REST API, I'm trying to auto populate a SharePoint list based on this form. I have other forms and I'm using a similar method and they all work. In this form although the string item (Marketing_info/Marketing_name) properly functions, meaning the entry is automatically created in SP list, unfortunately, I'm having troubles with the array item. So far, I tried to convert the array to a string, compose, and even tried to change the array to a string in the original form, which was not ideal as the form has some other purposes as well and this method also didn't work.

 

Here is what I have after removing all the failed steps:

 

 image.png

 

The HTTP request looks like this and I'm having problems with all the marketing_info/group_vu77r11 items

 

{
    "type": "object",
    "properties": {
        "Marketing_info/Marketing_name": {
            "type": "string"
        },
        "Marketing_info/group_vu7fr11": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "Marketing_info/group_vu7fr11/Active_Marketing": {
                        "type": "string"
                    },
                    "Marketing_info/group_vu7fr11/Countries": {
                        "type": "string"
                    },
                    "Marketing_info/group_vu7fr11/Marketing_Expiry_Date": {
                        "type": "string"
                    },
                    "Marketing_info/group_vu7fr11/Marketing_level": {
                        "type": "string"
                    },
                    "Marketing_info/group_vu7fr11/Population": {
                        "type": "string"
                    },
                    "Marketing_info/group_vu7fr11/Region": {
                        "type": "string"
                    },
                    "Marketing_info/group_vu7fr11/Start_date": {
                        "type": "string"
                    }
                },
                "required": [
                    "Marketing_info/group_vu7fr11/Active_Marketing",
                    "Marketing_info/group_vu7fr11/Countries_affected",
                    "Marketing_info/group_vu7fr11/Marketing_Expiry_Date",
                    "Marketing_info/group_vu7fr11/Marketing_level",
                    "Marketing_info/group_vu7fr11/Population",
                    "Marketing_info/group_vu7fr11/Region",
                    "Marketing_info/group_vu7fr11/Start_date"
                ]
            }
        }
}

Every time I add any of the array items, an Apply to each action is automatically created, however, I'm getting this error, although none of the items is null.

 

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@triggerBody()?['Marketing_Info/group_vu7fr11']' is of type 'Null'. The result must be a valid array.

 

As this is a very niche problem, there are no questions like this in the community, so any help is appreciated.

 

Many thanks, 

1 ACCEPTED SOLUTION

Accepted Solutions
Regular Visitor

Hi @abm 

 

Just as I replied to your previous comment, I realized my mistake. There was a problem with setting up the REST API, I omitted the array field "Marketing_info/group_vu7fr11" so Power Automate couldn't receive any inputs from the server. But thank you, your answer made me go back to check every step.

 

To reply your question, (also it might be useful for someone else), I direct the REST API to openfn.org which provides the basic structure of the JSON schema. I then use "Use sample payload to generate schema" option under the "HTTP request is received" action, which creates the schema automatically.

 

Thanks again, 

View solution in original post

4 REPLIES 4
Super User III
Super User III

Hi @thatakke 

 

In your JSON Schema required says

"Marketing_info/group_vu7fr11/Countries_affected",

 but above it defined as below

 

"Marketing_info/group_vu7fr11/Countries": {
                        "type": "string"
                    },

  

Not sure this is a typo error. you could correct these right name in both places.

 

If you are not expecting all fields as mandatory then remove the whole required tag from your schema

 

"required": [
                    "Marketing_info/group_vu7fr11/Active_Marketing",
                    "Marketing_info/group_vu7fr11/Countries_affected",
                    "Marketing_info/group_vu7fr11/Marketing_Expiry_Date",
                    "Marketing_info/group_vu7fr11/Marketing_level",
                    "Marketing_info/group_vu7fr11/Population",
                    "Marketing_info/group_vu7fr11/Region",
                    "Marketing_info/group_vu7fr11/Start_date"
                ]

 

Delete the above from the schema.

 

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!

Learn more from my blog

Power Automate Video Tutorials
Regular Visitor

Thanks @abm 

It's a typo, I just checked the original code, I somehow mistakenly changed it while posting to the forum.

 

After removing the required section, I still get the same error below. Any ideas?

 

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@triggerBody()?['Marketing_info/group_vu7fr11']' is of type 'Null'. The result must be a valid array.

Super User III
Super User III

Hi @thatakke 

 

Thanks for your reply. How you generated the schema? Check your last run history. Could you post a sample data of your JSON?

 

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!

Learn more from my blog

Power Automate Video Tutorials
Regular Visitor

Hi @abm 

 

Just as I replied to your previous comment, I realized my mistake. There was a problem with setting up the REST API, I omitted the array field "Marketing_info/group_vu7fr11" so Power Automate couldn't receive any inputs from the server. But thank you, your answer made me go back to check every step.

 

To reply your question, (also it might be useful for someone else), I direct the REST API to openfn.org which provides the basic structure of the JSON schema. I then use "Use sample payload to generate schema" option under the "HTTP request is received" action, which creates the schema automatically.

 

Thanks again, 

View solution in original post

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (4,625)