Share via

Automate teams user activity report using python SDK

Anonymous
2023-09-05T12:57:28+00:00

Hello Everyone,

  I have a problem: I need to automate the extraction of team user activity reports from the team admin center and store data needs to be S3 bucket in CSV format. For this, I have done app registration and with the help of Python SDK, I was trying to automate the process. But I'm getting the mentioned error.

Error Message:

msgraph.generated.models.o_data_errors.o_data_error.ODataError: APIError 404: None MainError(additional_data={}, code='UnknownError', details=None, inner_error=InnerError(additional_data={'date': datetime.timedelta(seconds=46105)}, client_request_id=6aabfa3e', date=None, odata_type=None, request_id='c5b7ff119'), message='{"error":{"code":"InvalidArgument","message":"The requested function cannot be found."}}', target=None)

The code I was using:

import asyncio
from azure.identity import DeviceCodeCredential
from msgraph import GraphServiceClient

scopes = ['Reports.Read.All']
tenant_id = 'Value from App registration'
client_id = 'Value from App registration'
client_secret = 'Value from App registration'

# azure.identity.aio
credential = DeviceCodeCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)

graph_client = GraphServiceClient(credential, scopes)

async def get_reports():
    await graph_client.reports.get_teams_user_activity_user_detail_with_period(period='D7').get()
asyncio.run(get_reports())

Can anyone please help with the solution?
Thanks in Advance!
Manoj
Microsoft 365 and Office | Install, redeem, activate | For business | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2023-09-05T16:27:59+00:00

    Hello Vaidya , Thanks for the clarification

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2023-09-05T13:58:32+00:00

    Hi Manoj Kumar Varadharajan,

    Good day.

    Thank you for connecting with us in Microsoft community.

    According to your mentioned description, seems like your concern environment is related to python SDK for teams user activity report which is associated with programming script, would you mind to connecting and placing this query in our dedicated Microsoft Q&A forum community so that relevant members of our community can provide possible information from their side? Because this forum does not support programming script related scenario, but as Microsoft has specific forum resource for certain different support scope and attributes.

    Thank you for your valuable time and kind cooperation.

    Sincerely,

    Darpan

    Was this answer helpful?

    0 comments No comments