Search code examples
zapierzapier-cli

Cant find information about acceptable response from my site to zapier app on test step (It's "Action" on my site )


I can't find information about acceptable response content or code status from my site to zapier app on test step.

I have my site on Laravel and Zapier app for this site. In my Zapier app I have an action: "Create New Project". I made my "create" according to the example. Everything works except the testing step. I tested with the following zap:

  • Trello -> "New card created" trigger. Test successful.
  • My app -> "Create new project". Test fails with We had trouble sending your test through. Could not handle special, non-standard characters. Please contact support.

Strangely, the project was created successfully. Therefore, I think the problem lies in the response from my site to zapier:

Screenshot of problem

// creates/project.js

// My perform function:
perform: (z, bundle) => {
  const promise = z.request({
    url: `${process.env.BASE_URL}/api/folder`,
    method: 'POST',
    body: JSON.stringify({
      title: bundle.inputData.title,
    }),
    headers: {
      'content-type': 'application/json',
    }
  });

  return promise.then((response) => JSON.parse(response.content));
}
//ZapierController.php

public function addFolder(Request $request)
{
    // Made record to DB, and other, after this returned same data which in request

    return response()->json(['title' => $request['title']]);
}

Expected result - successful test on "Test this step". Can anyone help me?


Solution

  • David here, from the Zapier Platform team.

    I already answered your support ticket, but I figured I'd reply here in case anyone else has the same issue.

    The root problem is made clear when you run zapier logs on the cli:

    == Log
    Unhandled error: CheckError: Invalid API Response:
      - Got a non-object result, expected an object from create ("title")
    What happened:
      Executing creates.сFolder.operation.perform with bundle
      Invalid API Response:
      - Got a non-object result, expected an object from create ("title")
    

    Your server can reply with any 2xx status code, but the output needs to be valid json. Something like {"title": "my title here"} would certainly work. Users find it more helpful to get info about the project they just created, so the name, id, etc would be even better.

    As for why this surfaced as a character encoding issue, I have no clue. We plan on getting to the bottom of it though!