Hi,
I'm currently working on REST API. I would like to create a file with last username connected to each model.
Based on something created by Karan Kochhar, I currently have extracted all model information (with the user id of the last modification)
Problem is I can't extract all users information and merge both array.
I assume I need to create a loop to get the name of the user for each model.
I tried this code but it's not working. Can you help to fix this issue ?
Thanks
Regards,
Yohan
models_response = anaplan.getModel(token)
for a in models_response['models']:
if a['activeState'] != 'ARCHIVED':
user_info_response = anaplan.getUsersInformation(a['lastModifiedByUserGuid'],token)
models_df =pd.DataFrame(models_response['models'])
output_df = pd.merge(models_df,user_info_response[['id','email','lastname','firstname']],left_on='lastModifiedByUserGuid', right_on='id')
------
def getModel(vToken):
model_header = {'Authorization':'AnaplanAuthToken ' + vToken}
r = requests.get(model_url, headers=model_header)
try:
r.raise_for_status()
except requests.exceptions.HTTPError as e:
print("Error: " + str(e))
exit()
return r.json()
def getUsersInformation(UserID,vToken):
header = {'Authorization':'AnaplanAuthToken ' + vToken,'Accept':'application/json'}
r = requests.get(getUsersInformation_url, headers= header)
try:
r.raise_for_status()
except requests.exceptions.HTTPError as e:
print("Error: " + str(e))
exit()
return r.json()