Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

json parsing error expected object but got array

(0) ShareShare
ReportReport
Posted on by

Hi...this is my first time posting to this forum. Thanks to anyone able to offer any solutions. I've been stumped on this error within my canvas app for quite a while now when I click the Submit New User button. I couldn't find much info on it, so I guess it's a pretty obscure problem.

MattyIcy_0-1678814522509.png

Onselect of the button, I have the formula entered:

 

ClearCollect(UserInsert,UserCollection);
Patch(UserInsert,Defaults(UserInsert),

{Company Name:'Company Input'.Text,Department:'Department Input'.Text,Email:'Email Input'.Text});
ClearCollect(UserSuccess,Azure_AD_Guest_Users_SFConnect.InsertUserData({schema:"xxxxx",table:"xxxxx",'Content-Type':"application/json",Accept:"application/json",body:UserSuccess}))

 

I'm trying to call a custom API/connector (Azure_AD_Guest_Users_SFConnect.InsertUserData) from my app that uses an Azure Function I built that's supposed to insert data into a snowflake DB. I've already built the custom connector according to an article I found explaining how all of this done. Find it here

And here's the request definition that I created for the custom connector (I can provide more detail here if needed).

MattyIcy_1-1678815267528.png

Fairly new to Power Platform, so any advice on this error is much appreciated. Please let me know if there's any additional information/files I can provide to help bring out a solution. Thanks!

Categories:
  • Pstork1 Profile Picture
    Pstork1 64,822 on at
    Re: json parsing error expected object but got array

    Please post this as a new question.  You'll get more responses and others will be able to find the answer more easily later. If you'll add some screenshots of the flow you are using and send me a link to the new post I'll try to help you there.

  • JimSInAz Profile Picture
    JimSInAz 17 on at
    Re: json parsing error expected object but got array

    I am SO ready to go running, screaming into the night!!!!! @Pstork1, you say that a collection is ALWAYS an array of objects. I created a Power Automate flow with a response schema that looks like:

    {
        "type""object",
        "properties": {
            "body": {
                "type""array",
                "items": {
                    "type""object",
                    "properties": {
                        "CONTRACT_ID": {
                            "type""integer"
                        },
                        "CONTRACT_ID_NOTE": {
                            "type""string"
                        },
    ...
    I use a ClearCollect(colContracts, SelectContracts002.Run(<variables>).body);
    and I get this @!%*ing "JSON Parsing error expected object but got array" error. If every collection is an array of objects then why the heck wouldn't the stupid "ClearCollect(colContracts..." be absolutely delighted to be receiving an array of objects?????? I seriously need someone who can explain all this to me.
  • Pstork1 Profile Picture
    Pstork1 64,822 on at
    Re: json parsing error expected object but got array

    Can't do much of an example since I don't have access to your custom connector.  But it would be something like this in place of the collection.

    Set(UserInsert,{Company Name:'Company Input'.Text,Department:'Department Input'.Text,Email:'Email Input'.Text});
    ClearCollect(UserSuccess,Azure_AD_Guest_Users_SFConnect.InsertUserData({schema:"xxxxx",table:"xxxxx",'Content-Type':"application/json",Accept:"application/json",body:UserInsert}))
  • Re: json parsing error expected object but got array

    Hi @Pstork1 , thank you for that. Makes perfect sense. Could you offer up either one of those solutions in a generic example? That way, I can see the exact syntax that I need to use.

     

  • Pstork1 Profile Picture
    Pstork1 64,822 on at
    Re: json parsing error expected object but got array

    The problem is that a collection is always an array of objects, even if there is only one object in the collection.  But your API is expecting you to pass it an object, not an array.  That's why you are getting the error.  You can either build the input as a record in a variable or use First() to get the first record in your collection when you do the submission.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,495

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,822

Leaderboard