1

I am exploring azure management APIs. The ADF monitor pipeline, returns only 100 records at a time. So I created a while loop, but for some reason, not sure what, not able to get the next token.

ct = d.get('continuationToken','')
c = 1
while ct!='':
    req_body = self.getDataBody(ct)
    data = self.getResponse(data_url,data_headers,req_body)
    nct = self.getContinuationToken(data,c)
    c = c+1
    print(c)
    if ct == nct:
        print(ct)
        print(nct)
        print('duplicate token')
        break
    ct = nct
    if ct == '':
        break

Here in the next iteration next token is not getting updated.

Update:

following the functions that the above code is using

def getDataBody(self,ct):
    start_date = datetime.now().strftime("%Y-%m-%d")
    end_date = (datetime.now() + timedelta(days=1)).strftime("%Y-%m-%d")
    data_body = {'lastUpdatedAfter': start_date, 'lastUpdatedBefore': end_date}
    if ct!='':
        data_body['continuationToken'] = ct
    return data_body


def getResponse(self,url,headers,body):
    data = requests.post(url,headers=headers,data=body)
    return data.text


def getContinuationToken(self,data,c):
    d = json.loads(data)
    with open(f'data/{c}.json','w') as f:
        json.dump(d,f)
    return d.get('continuationToken','')
Aman Khandelwal
  • 148
  • 1
  • 13

1 Answers1

0

you can try with increasing the timeout in the ADF activity may be due to the timeout setting in your current ADF activity is less than the actual time taking to execute that API .

RKM
  • 1,234
  • 1
  • 4
  • 9