Python Forum

Full Version: ebaysdk and pulling back customer feedback
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am working with ebaysdk and pulling back customer feedback. I get the results back, but do not know how to parse them correctly. I think they come back as json. Here is sample code.
api.execute('GetFeedback', {'ItemID':ItemID,'DetailLevel':'ReturnAll'}).dict()  # change for AddItem resource
#dump(api)
if api.response.reply.has_key('FeedbackDetailArray'):
   feedback = api.response.reply.FeedbackDetailArray.FeedbackDetail
   for ebay_return in feedback:
        print(ebay_return)
My results:
Output:
{'ItemID': '201632456626', 'CommentText': 'Love their promptness on answering questions! Product arrived exceptionally fast', 'FeedbackID': '137423231013', 'ItemPrice': {'_currencyID': 'USD', 'value': '1254.99'}, 'ItemTitle': '11881 Borla ATAK Rear Exhaust Fits 2014-2016 Chevy Corvette C7 6.2L V8 w/o NPP', 'CommentingUser': 'janellene.lopez0012', 'CommentTime': datetime.datetime(2017, 3, 3, 14, 2, 58), 'CommentType': 'Positive', 'TransactionID': '14934424962579010', 'OrderLineItemID': '20124296626-149392323010', 'CommentingUserScore': '1', 'Role': 'Seller'} {'ItemID': '2016043496626', 'CommentText': 'Great Buyer, fast payment, please come back anytime.', 'FeedbackID': '987637060024', 'CommentType': 'Positive', 'CommentingUser': 'midwestaftermarket2013', 'CommentTime': datetime.datetime(2017, 3, 1, 0, 35, 18), 'Role': 'Buyer', 'TransactionID': '1446577962579010', 'OrderLineItemID': '201607434626-14943439010', 'CommentingUserScore': '17991'}
If it is Json you get back: 
import json

feedback = api.response.reply.FeedbackDetailArray.FeedbackDetail
data = json.loads(feedback)
Now should data be dictionary and you parse it as a dictionary.
The dictionary has usually a mix of dict and list when data comes from Json.