Best answer

Invalid API Response: - Results must be an array error

  • 9 September 2020
  • 2 replies
  • 1387 views

Userlevel 1
  • Certified Zapier Expert
  • 1 reply

Hi guys

 

I am working on an app to get integrated with an e-commerce platform in Zapier. 

With the integration, I am trying to pull the data of order details from the resource server.

I have checked some similar cases on community but it seems like the codes used don’t wok on my case.

 

I am using Code Mode in Zapier. Here is my code:

 

const options = {
url: `https://clothshop1.cafe24api.com/api/v2/admin/orders/${bundle.inputData.order_id}/buyer`,
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${bundle.authData.access_token}`
},
params: {
'order_id': bundle.inputData.order_id
}
}

return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;

// You can do any parsing you need for results here before returning them

return results;
});
Invalid API Response: - Results must be an array, got: object, ({"buyer":{"shop_no":1,"member_id":"79254573@n","me) What happened (You are seeing this because you are an admin): Executing searches.order_idorder_id.operation.perform with bundle Invalid API Response: - Results must be an array, got: object, ({"buyer":{"shop_no":1,"member_id":"79254573@n","me) Console logs: Stack trace: CheckError: Invalid API Response: - Results must be an array, got: object, ({"buyer":{"shop_no":1,"member_id":"79254573@n","me) at checkOutput (/var/task/node_modules/zapier-platform-core/src/app-middlewares/after/checks.js:42:15) at Object.collector.then.newOutput (/var/task/node_modules/zapier-platform-core/src/middleware.js:80:37) at bound (domain.js:402:14) at Object.runBound (domain.js:415:12) at Object.tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:517:31) at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:574:18) at Promise._settlePromiseCtx (/var/task/node_modules/bluebird/js/release/promise.js:611:10) at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:142:12) at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:131:9) at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:147:5) at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:17:14) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5) at process.topLevelDomainCallback (domain.js:126:23)

It will be greatly appreciated if you guys can help me on this :-)

icon

Best answer by Mercology 9 September 2020, 16:30

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 4
Badge +5

@Haseok This is an easy one.  Triggers and Searches require an array of Objects to be returned.  Since your GET returns one item, you can make it into an array of 1 by putting braces around the return:

return [results];

This makes the results an array of 1 Object.

Userlevel 1

Super !

Oh thanks for the help !!! @Mercology 

Problem solved :-)