microsoft / semantic-link-labs

Early access to new features for Microsoft Fabric's Semantic Link.
MIT License
178 stars 37 forks source link

Getting Response 400: Bad Request for new list_activity_events function #211

Closed BadAtDax closed 1 month ago

BadAtDax commented 1 month ago

Describe the bug New admin.list_activity_events returns BAD RESPONSE 400 error message.

To Reproduce Steps to reproduce the behavior:

  1. Log into Fabric with an account that as Power BI/Fabric Administrator privileges
  2. Open new Spark Notebook
  3. In first cell, run pip install semantic-link-labs
  4. In new code cell, run the following code block:

    from sempy_labs import admin
    from datetime import datetime, timedelta
    
    endTime = datetime.utcnow() - timedelta(days=1)
    startTime = endTime - timedelta(days=14)
    
    startTime = startTime.strftime("%Y-%m-%dT%H:%M:%S")
    endTime = endTime.strftime("%Y-%m-%dT%H:%M:%S")
    
    print(f"Start Time: {startTime}")
    print(f"End Time: {endTime}")
    
    df = admin.list_activity_events(start_time=startTime, end_time=endTime)
    
    df.head(20)

Expected behavior Data is returned to a pandas dataframe and displayed

Error message returned

FabricHTTPException: 400 Bad Request for url: https://wabi-west-us-redirect.analysis.windows.net//v1.0/myorg/admin/activityevents?startDateTime=%272024-09-30T22:45:43%27&endDateTime=%272024-10-14T22:45:43%27
Headers: {'Cache-Control': 'no-store, must-revalidate, no-cache', 'Pragma': 'no-cache', 'Transfer-Encoding': 'chunked', 'Content-Type': 'application/octet-stream', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'X-Frame-Options': 'deny', 'X-Content-Type-Options': 'nosniff', 'RequestId': '772d911d-eced-474d-b0cb-e072c3b53b72', 'Access-Control-Expose-Headers': 'RequestId', 'Date': 'Tue, 15 Oct 2024 22:45:43 GMT'}

Desktop (please complete the following information):

Additional context I noticed that the base url variable in the function definition for list_activity_events probably needs to remove the first character /, however I made that change in a custom defined version of this function and I am still not able to get it to return anything other than this error response.

m-kovalsky commented 1 month ago

Please see the example given in the documentation regarding start/end times.

https://semantic-link-labs.readthedocs.io/en/stable/sempy_labs.admin.html#sempy_labs.admin.list_activity_events

BadAtDax commented 1 month ago

Thank you @m-kovalsky. I reviewed the docs you linked and the format looked like it aligned with mine. What I didn't realize is that I have to ensure that my datetime window is within the same UTC day: Image

Ensuring my start and end datetime are within the same day fixed my issue.

Cheers