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','')
4
  • Have you tried seeing if the response differs in the loop? maybe you're always getting the same response. Commented Aug 2, 2021 at 5:30
  • it differs if a manually run it multiple times by passing the updated continuation token, but in loop the token stays same Commented Aug 2, 2021 at 5:34
  • Have you tried writing a custom dummy getContinuationToken that always returns something different to see whether the problem will be gone or not? Commented Aug 2, 2021 at 5:36
  • yes, for other things the logic is working Commented Aug 2, 2021 at 6:09

1 Answer 1

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 .

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.