Skip to content
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

Find fedex tracking id by sender reference #83

Closed
Bobspadger opened this issue Nov 24, 2016 · 8 comments
Closed

Find fedex tracking id by sender reference #83

Bobspadger opened this issue Nov 24, 2016 · 8 comments

Comments

@Bobspadger
Copy link

Hi

Is there a way with this library to find tracking numbers from our account / reference number ?

We have several places of label creation etc (some online) and would like to recover the tracking ID's to our back office system.

Is this possible ?

Thanks

Alex

@Bobspadger
Copy link
Author

Answered own question:

track.SelectionDetails.PackageIdentifier.Type = 'SHIPPER_REFERENCE'

@yanpozka
Copy link

yanpozka commented Mar 1, 2017

Hello @Bobspadger, sorry for bother you, but you're the only person that I've found in the whole internet who is using a reference number to get the tracking number; were you able to make it work ??

Also I found here other 2 reference constants:
CUSTOMER_REFERENCE and FREE_FORM_REFERENCE

Do you know the difference? May you copy here how are you building the FedexTrackRequest object ?

A ton of thanks in advance

@Bobspadger
Copy link
Author

@yanpozka I think I did, I'm trying to remember which of my services I put this into, I'll try to find it.

@Bobspadger
Copy link
Author

@yanpozka Here is my quick proof of concept code, by sending in our shipping references (Dxxxx) I can recover the Fedex tracking id.

It seems to work 'ok'

# Get items from our DB, if it has a tracking ID and is NOT delivered - track.
# If it has no tracking ID - use the DNOTE and write the tracking ID back
import pymysql
import logging
import sys
from fedex.config import FedexConfig
from fedex.services.track_service import FedexTrackRequest
CONFIG_OBJ = FedexConfig(key='xxxxxxxxx',
                         password='xxxxxxxxx',
                         account_number='xxxxxxxxxx',
                         meter_number='xxxxxxxxx'
                         )

logging.basicConfig(stream=sys.stdout, level=logging.INFO)
customer_transaction_id = "*** TrackService Request v10 using Python ***"  # Optional transaction_id
# create tracking object - reuse it for the life of the script.
track = FedexTrackRequest(CONFIG_OBJ, customer_transaction_id=customer_transaction_id)

list_of_dnotes = ['D1146996',
                  'D1150735',
                  'D1151413',
                  'D1151637',
                  'D1152997',
                  'D1156228',
                  'D1160909',
                  'D1162593',
                  'D1163081',
                  'D1163865',
                  'D1164011',
                  'D1164740',
                  'D1165059',
                  'D1166083',
                  'D1166238',
                  'D1165608',
                  'D1167589']



def recover_fedex_tracking_id(dnote):
    # track.SelectionDetails.PackageIdentifier.Value = '671020973012'
    track.SelectionDetails.PackageIdentifier.Value = dnote

    #SHIPPER_REFERENCE
    # track.SelectionDetails.PackageIdentifier.Type = 'TRACKING_NUMBER_OR_DOORTAG'
    track.SelectionDetails.PackageIdentifier.Type = 'SHIPPER_REFERENCE'
    track.SelectionDetails.ShipmentAccountNumber = 'xxxxxxxxx'
    track.send_request()
    # print(track.response)
    return track.response


for delivery_note in list_of_dnotes:
    tracking_response = recover_fedex_tracking_id(delivery_note)
    try:
        print(tracking_response.CompletedTrackDetails[0].TrackDetails[0].TrackingNumber)
    except KeyError:
        print('thats not there!')

@yanpozka
Copy link

yanpozka commented Mar 1, 2017

@Bobspadger thanks a lot for your help. I really appreciate your answer and your full example, it helps!! I'll try following your example. Thank you !!

I must say you save my life !! it does work !!

@johnmudd
Copy link

@Bobspadger I appreciate your example. I just tried it for one of my packages (shipped a month ago) and got the following.

Message = "This tracking number cannot be found. Please check the number or contact the sender."

I was able to track this package via the fedex.com web page. But I provided the ship date on the web page.

I retried using Python by setting track.SelectionDetails.ShipDate but I got the following.

suds.TypeNotFound: Type not found: 'ShipDate'

Any suggestion?

@johnmudd
Copy link

Solved it.

track.SelectionDetails.ShipDateRangeBegin = '2017-05-09'
track.SelectionDetails.ShipDateRangeEnd = '2017-05-09'

@Bobspadger
Copy link
Author

@johnmudd glad to be of service :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants