EasyPost / easypost-java

EasyPost Shipping API Client Library for Java
https://easypost.com/docs/api
MIT License
53 stars 37 forks source link

[Bug]: Event payloads return empty #249

Closed yasnmert closed 1 year ago

yasnmert commented 1 year ago

Software Version

6.3.1

Language Version

17

Operating System

Macos

What happened?

No webhooks were registered at the time that this event was generated.

When we try to get the payload information of this event by using the payload endpoint ("events/" + eventId + "/payloads") , the response is empty.

{"payloads":[]}

What was expected?

We were waiting for the payload information to come.

Sample Code

No response

Relevant logs

No response

Justintime50 commented 1 year ago

Hey @yasnmert, this is the expected behavior. Per our documentation: A Payload represents an attempt by EasyPost to send an Event to a Webhook. You mentioned that there were no webhooks registered at the time the event was generated which means that there was no attempt to deliver data to a webhook. This would describe why the payload was empty.

To fix this issue, register a valid webhook and trigger a workflow that will deliver to a webhook (the list can be viewed here: https://www.easypost.com/docs/api#possible-event-types). Give it some time and once there is an attempt to deliver webhook data, the payload for that specific Event should be populated. You can then retrieve it the same way you mentioned above.

If you have additional questions on how our API works, you can reach out to our support team at support@easypost.com. Since this is not an issue specifically with this library, I'm going to close out this issue.

yasnmert commented 1 year ago

Thanks for your answer. Let me explain the question with an example. For example, I created a webhook then create a tracker flow and accidentally deleted the webhook. Incoming events belonging to that tracker remained in pending status. When I want to retrieve these events manually, the payload field of the events is empty. This causes us to miss events. The payload fields of the events in the pending status are empty. Can we get the payload part of these events?

Justintime50 commented 1 year ago

Hard to say without seeing any of the details myself. Can you provide a webhook and event ID?

Depending on the timing of these events, it's possible that the details won't be populated since a webhook was not registered when the data attempted to send. Because this process happens asynchronously, there could be delays in the timing which could have led it to be empty once it attempted to send.

yasnmert commented 1 year ago

Yes sure.

I created a tracker while I didn't have any webhook in the test environment. This is the tracker id: trk_a6e899c1fa8f45809f3c36565912d5c8

This is the id=evt_47c0855ccda911ed85a235cc90885fbc of one of the incoming events belonging to this tracker.

When I retrieve this event, I can get the following information. endpoint: "events/" + id;

{
  "description": "tracker.updated",
  "mode": "test",
  "previous_attributes": {
    "status": "unknown"
  },
  "created_at": "2023-03-28T20:44:06.000Z",
  "pending_urls": [],
  "completed_urls": [],
  "updated_at": "2023-03-28T20:44:06.000Z",
  "id": "evt_47c0855ccda911ed85a235cc90885fbc",
  "user_id": "user_74a9dc2c74214b8c82c53602ee3bf2fa",
  "status": "pending",
  "object": "Event"
}

But when I want to retrieve the payload part, I get an empty response. endpoint: "events/" + eventId + "/payloads";

{"payloads":[]}

I'm wondering if there is a way to manually retrieve the payload information in this scenario. Thank you for your help.

Justintime50 commented 1 year ago

Thanks for the example!

As you can see, both pending_urls and completed_urls are an empty list meaning there was no registered webhook at the time this event fired off.

Ultimately no, there is no way to retrieve a payload for an Event if there was no webhook registered at that time since there is no payload that exists for this event. Some alternatives are to register a new webhook and future events will attempt to send there, you should then be able to retrieve those payloads. Additionally, you can always retrieve the tracker related to this event and see the current status of a tracker and additional details that may have come back via that event.

yasnmert commented 1 year ago

Thank you for your help.