Skip to main content
Best answer

Trying to get the results after the JSON success.

  • April 2, 2021
  • 1 reply
  • 134 views

Here is my code that is returning the error. I want to return everything within “Data”

const options = {
  url: `${bundle.authData.server}/org/${bundle.authData.orgId}/profile/${bundle.inputData.profile_id}`,
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': `Token ${bundle.authData.token}`
  },
  params: {
    'profile_id': bundle.inputData.profile_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;
  });

The error I get is:

 

 

Invalid API Response: - Results must be an array, got: object, ({"successMsg":"Get profile information with campai) What happened (You are seeing this because you are an admin): Executing searches.get_candidate.operation.perform with bundle Invalid API Response: - Results must be an array, got: object, ({"successMsg":"Get profile information with campai)

 

 

{
   "successMsg":"Get profile information with campaigns info",
   "status":"success",
   "statusCode":200,
   "data":{
      "profile_info":{
         "last-active-date":"1617391026",
         "opt-in-date":"1617391002",
         "opt-in":"Yes",
         "name":"Paul Collins",
         "first-name-auto":"Paul",
         "last-name-auto":"Collins",
         "email":"paul@roborecruiter.ai",
         "mobile":"14155556666",
         "availability":"1 month",
         "availability-date":"1619983026",
         "availability-value":"1"
      },
      "campaign_info":[
         {
            "campaignid":63651,
            "rundate":1611680490,
            "campaignname":"Activation Flow",
            "medium":"channel"
         }
      ]
   }
}

 

Best answer by ikbelkirasanBest answer by ikbelkirasan

@cozza13 - Try this:

const options = {
  url: `${bundle.authData.server}/org/${bundle.authData.orgId}/profile/${bundle.inputData.profile_id}`,
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    Accept: "application/json",
    Authorization: `Token ${bundle.authData.token}`,
  },
  params: {
    profile_id: bundle.inputData.profile_id,
  },
};

return z.request(options).then((response) => {
  response.throwForStatus();
  const profile = Object.assign({}, response.json.data, {
    id: bundle.inputData.profile_id,
  });
  return [profile];
});

 

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • Answer
  • April 2, 2021

@cozza13 - Try this:

const options = {
  url: `${bundle.authData.server}/org/${bundle.authData.orgId}/profile/${bundle.inputData.profile_id}`,
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    Accept: "application/json",
    Authorization: `Token ${bundle.authData.token}`,
  },
  params: {
    profile_id: bundle.inputData.profile_id,
  },
};

return z.request(options).then((response) => {
  response.throwForStatus();
  const profile = Object.assign({}, response.json.data, {
    id: bundle.inputData.profile_id,
  });
  return [profile];
});