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

Network Error when using Patch function: The requested operation is invalid

I'm getting an error when patching a SharePoint list from a PowerApp with little to no information to work off of. The only message is "Network Error when using Patch function: The requested operation is invalid". I dug into the Error object and found a code of 8, which I believe corresponds to ErrorKind.ConstraintViolation (One or more constraints have been violated).

 

I have narrowed down the error to a multiple-select Person or Group column in my SharePoint list called "Operators". When I comment that column out, the Patch is successful. When it's included, I get the error above. The worst part is, I have successfully patched to a Person or Group column in a different SharePoint list, but this one fails.

 

Column settings:

shoeheart_0-1637102851350.png

 

My code that is failing:

 

Patch(
            'SharePoint List Name',
            Defaults('SharePoint List Name'),
            {
                Title: "Title",
                Zone: {Value: sel_sh_zone_name},
                Shift: {Value: sel_shift_name},
                Line: {Value: sel_line_name},
                Date: DateValue(DateDisplay_Component_12.datasource),
                Operators: AddColumns(
                    operators_select.SelectedItems,
                    "Claims",
                    "i:0#.f|membership|" & Mail,
                    "Email",
                    Mail,
                    "Picture",
                    "https://<base_site_url>/_layouts/15/UserPhoto.aspx?Size=L&AccountName=" & Mail
                )
            }
        )

 

 

The operators_select.SelectedItems is a Office365Users table. I need to add the "Claims", "Email", and "Picture" columns in order to avoid Table schema errors. Before attempting the Patch, no errors/warnings show up. Like I said, this strategy has worked successfully in another SharePoint list with this column type. I've scoured settings and haven't found any differences yet.

 

If anyone has any ideas for what to look at next or how to get more detail on the error message, please let me know! Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @shoeheart ,

 

Please make sure that the 'Mail' column of each record has a value rather than blank.

vxiaochenmsft_0-1637304919682.png

 

In addition ,you could use ""

instead of 

"https://<base_site_url>/_layouts/15/UserPhoto.aspx?Size=L&AccountName=" & Mail

 

Best Regards,

Wearsky

 

View solution in original post

4 REPLIES 4
v-xiaochen-msft
Community Support
Community Support

Hi @shoeheart ,

 

Please make sure that the 'Mail' column of each record has a value rather than blank.

vxiaochenmsft_0-1637304919682.png

 

In addition ,you could use ""

instead of 

"https://<base_site_url>/_layouts/15/UserPhoto.aspx?Size=L&AccountName=" & Mail

 

Best Regards,

Wearsky

 

Hi @v-xiaochen-msft,

 

Thank you for the input. You are spot-on with the "Mail" column needing a value. I did a bunch of manual testing and found that it when it was missing, I got the error. I also saw that the Picture field did not throw an error if it was just passed an empty string.

 

However, the reason it is not there is confusing. In one set of code, I Patch successfully to the first list because the Mail field is included in the records of "operators_select.SelectedItems". However, the Mail field disappears from the records before the second Patch.

 

I worked around this by setting a variable to collect this section into a Table:

 

Operators: AddColumns(
                    operators_select.SelectedItems,
                    "Claims",
                    "i:0#.f|membership|" & Mail,
                    "Email",
                    Mail,
                    "Picture",
                    "https://<base_site_url>/_layouts/15/UserPhoto.aspx?Size=L&AccountName=" & Mail
                )

 

I then passed the Table variance to both Patch functions and it worked. But, the Mail field is still deleted from the operators_select.SelectedItems, so I have to ask the user to re-add selections to the combobox if they want to make any edits.

 

I am going to mark this one as correct because it fixed the issue at hand, though it revealed what I think the root of the problem is.

 

Short version - the error message was caused by the request being sent without the Mail field populated. This is required for SharePoint to know what Person it is.

 

Longer version - for my app, I found out that when I perform a Patch, most of the data on the Person objects in my Combobox seems to "disappear" from the objects. The only ones that remained were unhelpful. I worked around this by building a Person object on a variable and sending that one to two different Patches. In my previous setup, the first Patch was successful, but the data was somehow deleted in between the two Patches. Very strange.

@v-xiaochen-msft sorry this is random, but I am facing a similar issue. I am new to powerapps and would appreciate if you could explain about -"'Mail' column of each record has a value rather than blank." I did not quite understand. Thanks.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,584)