Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to get the data
#1
Hi All,

I am trying to get one of the value named as "TotalNumberOfProducts" from one of the API.The API is below
http://xx:8080/maintenance/job?jobType=IMPORT&resultLimit=30
i was able to get other parameters like recordsprocesed,jobid etc and tried the below code to get the required data
#totalProducts=responseurl['statistics'].get('totalProducts')[0]
#totalProducts=responseurl[1]

both the ways are not giving any result Could you please assist as am new to this language.

responseurl = requests.get('http://xx:8080/maintenance/job?jobType=IMPORT&resultLimit=30')
                if(responseurl.ok):
                        jData = json.loads(responseurl.content)
                        #print jData
                        if jData > 0:
                                for responseurl in jData['response']:
                                        starttime=responseurl['statistics']['startTime']
                                        jobId= responseurl['jobId']
                                        status = responseurl['status']
                                        catalogId = responseurl['catalogId']
                                        recordsProcessed=responseurl['statistics']['recordsProcessed']
                                        recordsFailed=responseurl['statistics']['recordsFailed']
                                        fileName=responseurl['fileName']
                                        duration=responseurl['statistics']['duration']
                                        throughput=responseurl['statistics']['throughput']
                                        
API output

{u'response': [{u'status': u'COMPLETE', u'statistics': {u'estimatedTimeToFinish': u'0 seconds', u'workExpected': 1613, u'recordsFailed': 0, u'throughput': 322, u'percentComplete': 100, u'startTime': u'2019-05-22T11:55:01.642Z', u'duration': u'5 seconds', u'recordsProcessed': 1613, u'endTime': u'2019-05-22T11:55:07.126Z'}, u'expirationDatetime': u'2019-05-25T11:55:01.639Z', u'completedSteps': [{u'statistics': {u'workExpected': 1, u'recordsFailed': 0, u'throughput': 0, u'percentComplete': 100, u'startTime': u'2019-05-22T11:55:01.642Z', u'duration': u'0 seconds', u'recordsProcessed': 1, u'endTime': u'2019-05-22T11:55:01.653Z'}, u'workExpected': 1, u'catalogId': u'xx', u'header': {u'language': u'xx', u'totalProducts': 1332, u'country': u'xx', u'catalogId': u'xx', u'currency': u'xx', u'version': u'xx', u'partnerCode': u'xx'}, u'concreteType': u'CreateCatalogStep', u'workType': u'CREATE'}, {u'statistics': {u'workExpected': 256, u'recordsFailed': 0, u'throughput': 0, u'percentComplete': 100, u'startTime': u'2019-05-22T11:55:01.653Z', u'duration': u'0 seconds', u'recordsProcessed': 256, u'endTime': u'2019-05-22T11:55:01.757Z'}, u'workExpected': 256, u'fileName': u'/xx', u'catalogId': u'xx', u'concreteType': u'CategoryImportFromFileStep', u'workType': u'CATEGORY_IMPORT'}, {u'workExpected': 1, u'statistics': {u'workExpected': 1, u'recordsFailed': 0, u'throughput': 0, u'percentComplete': 100, u'startTime': u'2019-05-22T11:55:01.757Z', u'duration': u'0 seconds', u'recordsProcessed': 1, u'endTime': u'2019-05-22T11:55:01.781Z'}, u'concreteType': u'EvictCacheStep', u'workType': u'EVICT_CACHE', u'catalogId': u'xx'}, {u'statistics': {u'estimatedTimeToFinish': u'0 seconds', u'workExpected': 1332, u'recordsFailed': 0, u'throughput': 266, u'percentComplete': 100, u'startTime': u'2019-05-22T11:55:01.781Z', u'duration': u'5 seconds', u'recordsProcessed': 1332, u'endTime': u'2019-05-22T11:55:07.023Z'}, u'workExpected': 1332, u'bsinsRequiringSupplierSelection': [], u'catalogId': u'xx', u'startFrom': 0, u'merchantsProcessed': [u'xx'], u'fileName': u'xx', u'concreteType': u'ImportProductsFromFileStep', u'workType': u'IMPORT'}, {u'merchants': [u'xx'], u'statistics': {u'workExpected': 23, u'recordsFailed': 0, u'throughput': 0, u'percentComplete': 100, u'startTime': u'2019-05-22T11:55:07.023Z', u'duration': u'0 seconds', u'recordsProcessed': 23, u'endTime': u'2019-05-22T11:55:07.117Z'}, u'workExpected': 23, u'lastImportDateTime': u'2019-05-22T11:55:01.781Z', u'catalogId': u'xx', u'bsinsRequiringSupplierSelection': [], u'concreteType': u'ExpireMerchantProductsStep', u'workType': u'EXPIRE'}, {u'statistics': {u'workExpected': 0, u'recordsFailed': 0, u'throughput': 0, u'percentComplete': 0, u'startTime': u'2019-05-22T11:55:07.117Z', u'duration': u'0 seconds', u'recordsProcessed': 0, u'endTime': u'2019-05-22T11:55:07.125Z'}, u'workExpected': 0, u'catalogId': u'xx', u'concreteType': u'SelectPreferredSupplierStep', u'multiSupplierProducts': [], u'workType': u'SELECT_SUPPLIER'}], u'jobId': 7620, u'startFrom': 0, u'pendingSteps': [], u'fileName': u'/xx', u'catalogId': u'xx', u'jobType': u'IMPORT'},
Reply


Messages In This Thread
Unable to get the data - by pythonFresher - May-22-2019, 12:21 PM
RE: Unable to get the data - by ichabod801 - May-22-2019, 12:56 PM
RE: Unable to get the data - by michalmonday - May-22-2019, 01:10 PM
RE: Unable to get the data - by buran - May-22-2019, 01:23 PM
RE: Unable to get the data - by pythonFresher - May-22-2019, 02:35 PM
RE: Unable to get the data - by buran - May-22-2019, 03:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to request image from FORM Data usman 0 1,016 Aug-18-2022, 06:23 PM
Last Post: usman
  Unable to Validate csv blanck data and write in csv prashant18 0 1,561 Jul-25-2020, 12:08 PM
Last Post: prashant18
  Unable to do the proper split using re.sub incase of missing data. Karz 1 1,892 Nov-17-2019, 05:58 PM
Last Post: buran
  unable to indent json data dataplumber 4 3,064 Oct-22-2019, 01:55 PM
Last Post: dataplumber
  Unable to read data from string base64 representing a .xlsx file max 2 15,383 Apr-05-2018, 07:58 PM
Last Post: max

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020