web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Custom Connector: Arra...
Power Apps
Answered

Custom Connector: Array expected, but object received

(0) ShareShare
ReportReport
Posted on by 15

I've created a custom connector to GET and POST images to the Media Library from Wordpress. 

This is the endpoint: https://mywebsite/wp-json/wp/v2/media

 

The function that I created is Wordpress.UploadImages(imagefile).

 

My goal is to upload images to the Wordpress Media library using the Camera Control and then connect them to the Woocommerce product that is being edited in Power Apps. The Product ID is found by using a unique number (the SKU) of the product. 

I want to upload two collections: colExistingImages (the already existing images in Woocommerce for the product) and the colNewProductImages (images that are collected via the Camera Control). 

 

I use the ImagesIds to put the collections together (I don't know if there is a better way to do this, but this worked for me).

 

When I try to upload the images via the Custom Connector I get the error "JSON-parse error: Array was expected, but object is received". The images are uploaded correctly, but Power Apps doesn't seem to be able to obtain the response correctly. What can I do to receive the single objects from the response and put them in a collection? 

 

I've also added the custom connector swagger.json.

Any help is appreciated!

 

 

 

//Get product ID based on Text input (SKU)
Set(varProduct;WoocommerceAPI.GetProductID(varCurrentRecord.SKU));;
Set(varProductId;First(varProduct).id);;

//Get existing product images
Set(varProductImages;WoocommerceAPI.GetImagesFromProduct(varProductId));;
ClearCollect(colExistingImages;varProductImages.images);;

//Add camera photos to VarNewProductImages collection
Collect(
 colNewProductImages;
 ForAll(
 colCameraPhotos;
 Wordpress.UploadImages(ThisRecord.Base64String)
 )
);;

//Design the structure of ImagesIds collection
ClearCollect(
 ImagesIds;
 {
 name: "text";
 images: [{id: 0}]
 }
);;

//Collect Image ID's from Camera Control and from Existing Product images in ImagesIds collection
ClearCollect(
 ImagesIds;
 ForAll(
 colExistingImages;
 ThisRecord.id
 );
 ForAll(
 colNewProductImages;
 ThisRecord.id
 )
);;

//Add Image ID's to the specific product
WoocommerceAPI.AddImagesToProduct(
 varProductId;
 {
 images: ForAll(
 ImagesIds;
 {id: ThisRecord.Value}
 )
 }
)

 

 

 

 

Categories:
I have the same question (0)
  • dude1 Profile Picture
    15 on at

    I have checked the response with Postman and the response is indeed a single object. So what I also tried is to put the response in a variable with the Set() function, however I get the same error: "JSON-parse error: Array was expected, but object is received".

     

    Set(varResponse;Wordpress.UploadImages(First(colCameraPhotos).Base64String))

     

  • Verified answer
    dude1 Profile Picture
    15 on at

    It seems that my swagger file was not setup correctly (or it might be a bug in the Power Apps custom connectors). I had two functions GetImages and UploadImages. The first function (Get) expects an array as response. The second function (Post) expects an object as response. It looks like Power Apps thinks that an array should be received from the UploadImages function as a response even though it is stated in the response that an object should be received. 

    I've recreated the custom connecter and removed the first function (GetImages), now everything is working fine.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 166

#3
sannavajjala87 Profile Picture

sannavajjala87 71 Super User 2026 Season 1

Last 30 days Overall leaderboard