-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_tracking for postnl-3s courier #23
Comments
You need to create tracking first before you want to get a tracking. For example, from aftership import tracking
response = tracking.create_tracking(tracking={
"slug": "postnl-3s",
"tracking_number": "abcxyz",
"tracking_destination_country": "USA",
"tracking_postal_code": "12345"
})
tracking_id = response["tracking"]["id"]
tracking_response = tracking.get_tracking(tracking_id=tracking_id)
print(tracking_response) |
Thank you for your reply @alviezhang, but that does not help my case. |
@evoloshchuk Some couriers require users must specify some fields when create a tracking. You can check it in the official document https://docs.aftership.com/api/4/couriers/get-couriers. From my side, I can get these information from the ...
"required_fields": [
"tracking_destination_country",
"tracking_postal_code"
],
... |
@alviezhang the problem is not to figure out what fields are required to create a tracking (that part works), but to retrieve such tracking afterwards without tracking_id. tracking.get_tracking methods support look up by slug & tracking_number, which is not enough in the case when additional fields are required - and there is no way to pass those additional parameters. So, for postnl-3s case Hence my request is to make it possible to specify tracking_number & tracking_destination_country for the tracking.get_tracking method. Hope it's clear. |
@evoloshchuk Understood. This is an API behavior, I need to confirm with the relevant colleagues. |
As you can see, the Pro tips in https://docs.aftership.com/api/4/trackings/get-trackings-slug-tracking_number shows
The unique key we locate a tracking is slug, tracking_number and any other required fields. Most of couriers has no other required fields, so you can get the tracking through slug and tracking number. For slug This is an API design issue, we should not treat |
Any progress on this issue? Thanks. |
Postnl-3s courier requires tracking_destination_country and tracking_postal_code to be specified to retrieve a tracking.
However, currently it's not possible to specify those via aftership.tracking.get_tracking method (it only allows for the optional_keys to be passed along).
Details:
aftership.tracking.get_tracking(slug="postnl-3s", tracking_number="XYZ")
throws
aftership.exception.BadRequest: BadRequest: \'tracking_destination_country\' is required.
and then (once the first one is hacked in)
aftership.exception.BadRequest: BadRequest: \'tracking_postal_code\
is required.`The text was updated successfully, but these errors were encountered: