cancel
Showing results for 
Search instead for 
Did you mean: 

Activity Event APIs is unusable (Object must implement IConvertible)

Hello, when issuing example query to Activity Events API i'm getting the following response:

    "json": {
        "error": {
            "code": "BadRequest",
            "details": [
                {
                    "message": "Object must implement IConvertible.",
                    "target": "startDateTime"
                },
                {
                    "message": "Object must implement IConvertible.",
                    "target": "endDateTime"
                }
            ],
            "message": "Bad Request"
        }
    },

This is the output from Ansible, but i'm getting the same response through the Try It at https://docs.microsoft.com/en-us/rest/api/power-bi/admin/getactivityevents

 

This is my ansible resource config:

   - name: Retrieve PowerBI Activity Events
     uri:
       url: "https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime={{ '2020-09-01T00:00:00.000Z' | urlencode }}&endDateTime={{ '2020-09-18T00:00:00Z' | urlencode }}"
       method: GET
       headers:
         Authorization: "Bearer {{ powerbi_access_token }}"
       status_code: 200
       return_content: yes
       validate_certs: no
     register: activity_response

 

Status: New
Comments
bdarbo78
Frequent Visitor

You can only retrieve 24 hrs of activity events. Ex:
startDateTime = '2020-09-17T00:00:00.000Z'
endDateTime = '2020-09-17T23:59:59.000Z'

Anonymous
Not applicable

Still getting exactly the same error with date range lower than 24h

bdarbo78
Frequent Visitor

Have you tried building a URL similar to what is provided in the examples of the API documentation ?
e.g.  https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime=2019-08-13T07:55:00.000Z&endDa...

In these examples, there are no "{{...| urlencode }}". 

 

Maybe also worth noting, in your example, the second parameter ends with '.00Z' and not '.000Z'.

Anonymous
Not applicable

urlencode in Ansible converts special characters to their url-safe representation, eg: whitespace to %20, added it because i was trying different formats, doesn't make a difference for the given examples.

and answering your suggestion it doesn't make any difference whether i add microseconds part or not, still getting the same error

bfernandez
Resolver II

@Anonymous I figured this issue out. It is because you must encapsulate the startDateTime and endDateTime in single quotaion marks as shown below:

bfernandez_0-1613681417874.png

Hope this helps! I was going crazy trying to figure it out as well.

Also keep in mind that as of now you can only pull this type of data within 24 hours of the start and end DateTime.

fvalencia
Regular Visitor

BFernandez solved my issue, using single quote for dates works for me as well.