GraphQL Webhook not working

Hi @afroznissar
No problem at all!. I did, but it was rejected actually.
Are there a lot of accounts you need to set it up for? Do you want me to re-open the request?
Thanks in advance!
Tom

Hi @tomasw

Well, we need to enable it for all our active clients. We probably have around 15-20 of them right now. We would then also need to set it up for all new accounts moving forward. If we happen to forget or miss one due to human error, we wouldn’t easily know that it was missed.

So yeah, it would be great if we could re-open the request.

Thank you!

Afroz

Hi @afroznissar!
Thanks for that info.

Is it common practice to change webhooks on your accounts? or you subscribe to them once and rarely change them?

(I already made the request but to get more information in the meantime)

Thanks again!
Tom

Hi @tomasw!

No, until now, we’ve never needed to change webhooks after subscribing to them. Even if that needs to happen in the future, it will be rare. However, it will be common for us to need to subscribe to them in bulk across all our active customer accounts.

And if it helps, here’s our business case: we are integrating Shiphero with our internal invoice management systems as well our internal mini-ERP. So we need to track all shipments for all our clients. We can’t use Shiphero’s billing module for various reasons so this integration will save us a LOT of time and human error.

Thanks Tomas!

Hi @afroznissar!
Thanks for the patience while we discussed this internally.

Unfortunately, we will not be able to build this right now.

In case it helps, a suggested workflow to automate this, would be something like this:

  1. Get the customer accounts:

     query {
       account {
         data {
           customers {
             edges {
               node {
                 id
               }
             }
           }
         }
       }
     }
    
  2. Iterate through all of those IDs and see the webhooks registered using:

        query {
          webhooks(customer_account_id: "QWNjb3VudDo3NTU2") {
            request_id
            complexity
            data {
              edges {
                node {
                  shop_name
                  name
                  url
                  source
                }
              }
            }
          }
        }
    
  3. Comparing the registered Webhooks to the ones they should have, and if they don’t have them all, register it by using:

    mutation {
    webhook_create(
    data: {
    customer_account_id: “QWNjb3VudDo3NTU2”
    name: “PO Update”
    url: “https://someValidURL.com/webhook
    }
    ) {
    request_id
    complexity
    webhook {
    name
    url
    }
    }
    }

I apologize for the inconvenience and thanks for the patience!
Tom

I am also having trouble understanding how the webhooks work.
So I created webhook for order cancel and update shipment but when I cancel an order the url that I added in the hook is not being hit. I read all you wrote. When I execute this query -
query {
account {
request_id
complexity
data {
id
legacy_id
is_3pl
customers {
edges {
node {
id
legacy_id
}
}
}
}
}
}
I get this -
{
“data”: {
“account”: {
“request_id”: “6033ce503c206af2afbb40e7”,
“complexity”: 101,
“data”: {
“id”: “QWNjb3VudDo1MTg1NQ==”,
“legacy_id”: 51855,
“is_3pl”: false,
“customers”: {
“edges”: []
}
}
}
}
}
It shows “is_3pl”: false, so I am trying to create hook for this account_id 51855 but then I get the error Cannot access the requested resource. Permission denied.
Any ideas what I am doing wrong and how to properly create webhook for these events?

Regards,
GM

Hi @gmuradov93!
Thanks for reaching out!
Do you have the request_id for when you try to register the webhook?
Thanks in advance!
Tom

yes here is the response with the request_id
{
‘errors’ => [
{
‘code’ => 7,
‘operation’ => ‘webhook_create’,
‘field’ => ‘webhook_create’,
‘message’ => ‘Cannot access the requested resource. Permission denied’,
‘request_id’ => ‘6034c99ace50843fa9019647’
}
],
‘data’ => {
‘webhook_create’ => undef
}
}

Thanks for sharing that @gmuradov93!
It seems to be because you are using the Bearer from account id 51855 and also including the field customer_account_id: "51855". So the Mutation is “looking” for customer ID 51855 on account 51855.

There are two options.

  1. Use the Bearer from the 3PL + customer_account_id: "51855"
  2. Use the Bearer from the Child account 51855 and don’t include customer_account_id: "51855"

In your case I would suggest not sending customer_account_id: "51855" and it should work.
Thanks again!
Tom

Thanks for the fast response.
As I said when I create webhook without customer_account_id its all good - the webhook is created and when I fetch for webhoks I get as a result the hook that I just created. But when I cancel an order the URL that I added in the hook does not get hit therefore its not working any ideas why this could be? Here is the response I get when I create the webhook

 {
          'webhook_create' => {
                                'complexity' => 5,
                                'request_id' => '6034f8a548eb55e7c10d9a88',
                                'webhook' => {
                                               'url' => 'http://awf7.gyunay.prim.bg/api/RPC.integrations.3PLShipHero.handleCancelOrderHook?token=123',
                                               'name' => 'Order Canceled'
                                             }
                              }
        }

Hi @gmuradov93!
We were able to find logs about this!
It seems like the URL is responding with:

"response" : {
		"method" : "handleCancelOrderHook",
		"status" : "ERROR",
		"id" : 18,
		"package" : "RPC::integrations::3PLShipHero",
		"data" : [
			"Died"
		]
	}

Any chance you might be having an error while handling the webhook? this was sent at 2021-02-22T11:35:15.040-03:00

Thanks again!
Tom

Well thats weird because my URL got hit yesterday right after you wrote this post not on 22.02.2021 when the order was canceled… And another question I didn’t get anything as body, shouldn’t I be getting at least the number of the canceled order like this ?

{
  "order_number": "123456",
  "fulfillment-status": "canceled"
}

I modified the url to hit an asp file will see what I get there.

PS - I had problems with proxies on my server so now I am receiving the body.
Thanks all for the help. Everything works well now.

1 Like