Best answer

Not getting any of the Trigger test data through in PHP

  • 12 February 2020
  • 10 replies
  • 3010 views

Userlevel 1

Hi guys,


I'm new to Zapier and am trying to set up a trigger that inserts data using our api. When testing it however, I don't seem to get any of the entered test data though.


I have entered the test data into Zapier as you can see below:

image.png

In our code I have tried the following to get e.g. the api_partner_id:

$postData = json_decode(file_get_contents('php://input'), true);

$api_partner_id = $postData['api_partner_id']

=> empty result

$postData = json_decode(file_get_contents('php://input'), true);

$api_partner_id = $postData['inputData']['api_partner_id'] //(i saw in the raw version of the test data dat all data is put into 'inputData'

=> empty result

$api_partner_id = $_POST['api_partner_id']

=> empty result


When I run the test, the funny thing is that the Request data only contains {"hookUrl":"https://hooks.zapier.com/fake-subscription-url"} according to what I can see in Zapier


Can anyone help me or guide me to some sort of tutorial pretty please? I have already spent more time on getting everything to work in Zapier than writing the API itself 😂

Thanks!


icon

Best answer by jesse 21 February 2020, 20:38

Adding transparency around a reply from a member of our support team:

It looks like you have a New Sessions Trigger set up, which uses RESTHooks to trigger. When that "subscribe" call runs, it will send something like

{"hookUrl":"https://hooks.zapier.com/fake-subscription-url"}, because it's attempting to create a webhook subscription on your API so that the Zap will trigger each time a new session is added.

Then, separately, you have an Action set up called "Session Input Update". That's where all those fields are needed. It may also help to note that action is completely separate from the Trigger, and will not interact with it in any way."

@matsraemen could you let us know more about what Trigger and Action you'd like to set up here, and specifically what you're aiming to do with that "Session Input Update" Action?

Feel free to reply to your open support ticket on this as well. :)


View original

This topic has been closed for comments

10 replies

Userlevel 4
Badge +4

Hi @matsraemen,

The Zapier test is only checking that a trigger can successfully be initiated on your API side. If the server responds with status: 200 or 201 and nothing else it would make sense that you only get tho hookUrl. On the live side of the app that URL would be real.


What isn't clear to me is if your API is rejected the test because of a bad api_partner_id or is completing the request but you are getting nothing because it's not actually pointing to anything.


A couple questions/ideas that came up:

1) Are you using a REST hook or polling method for your trigger set up? The back end is different for each one.

2) Do you have a method to request webhook details? This would give you a better confirmation of what you are actually creating on your API's side.

3) What is your API supposed to return on a successful webhook creation? I have seen API's that only return the status code. If it just returns the status code do you need/want it to return details about the newly created webhook?


Userlevel 2
Badge

If you are building an integration, jump on the slack group https://zapier-platform.slack.com/

Other devs and Zapier team members can help you out.


Userlevel 7
Badge +8

Hey @matsraemen and @Patrick!

Just an FYI that we are phasing out that Slack group this year and will be encouraging folks to post in the Developer Discussion category of this community for help with their integrations. Our team monitors all new posts and our platform team is ready to jump in should folks have questions like these. 😊

In the meantime, I will be escalating this to the team that handles developer application questions. Please be on the lookout for a response from them via email to troubleshoot this!



Userlevel 7
Badge +8

Adding transparency around a reply from a member of our support team:

It looks like you have a New Sessions Trigger set up, which uses RESTHooks to trigger. When that "subscribe" call runs, it will send something like

{"hookUrl":"https://hooks.zapier.com/fake-subscription-url"}, because it's attempting to create a webhook subscription on your API so that the Zap will trigger each time a new session is added.

Then, separately, you have an Action set up called "Session Input Update". That's where all those fields are needed. It may also help to note that action is completely separate from the Trigger, and will not interact with it in any way."

@matsraemen could you let us know more about what Trigger and Action you'd like to set up here, and specifically what you're aiming to do with that "Session Input Update" Action?

Feel free to reply to your open support ticket on this as well. :)


Userlevel 7
Badge +8

@matsraemen It sounds like you were able to get this resolved. Would you be up for sharing the solution in this thread to help others?


Userlevel 1

I would really love to hear the solution here. I too cannot get any of the data that Zapier is supposedly sending into my application using PHP and all of the methods tried by OP.

Likewise -- I’ve set the Trigger to be a REST Hook - 

Which creates a hook in our application with this URL: https://hooks.zapier.com/fake-subscription-url

Then, when we create a ZAP -- it asks us to “copy this URL into your app’s hook configuration”.  I don’t want to do this for every ZAP - isn’t the idea of the REST Hook to avoid this kind of user-triggered behaviour?

 

Meanwhile - the pre-validation check is giving me a warning saying “Static Hook Is Discouraged”.  I cannot see where I’m supposed to make it not static - I’ve selected “REST Hook” and there is ntohing in the documentation about this.

Appreciate some help/guidance.  Usually can follow documentation but it appears to be lacking.

Userlevel 1

Nils,

 

This was happening for us because we had not fully implemented the remaining methods. If you have unimplemented methods, particularly the unsubscribeHook method, try implementing them with something basic, like a placeholder that returns HTTP 200 status.

Thanks Jack. I'll try that.  We have an unsubscribe endpoint but I've been having trouble with that also.  Maybe that is the problem.  The problem I have there is bundle.subscribeData.id is always undefined.

I'll temporarily change the endpoint to just return 200 and see if that helps with the first problem.

Thanks Jack - switching the unsubscribe hook to an endpoint that simply returns 200 - did seem to fix both of my first problems.

Now I need to get the real unsubscribe hook endpoint working.  Having trouble with bundle.subscribeData.id