Skip to main content

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 nas _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 :-)

@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 rresults];

This makes the results an array of 1 Object.


Super !

Oh thanks for the help !!! @Mercology 

Problem solved :-)