Accessing the Data API using a token

hi,
I think I have discovered a “newly introduced” bug.

I am accessing an endpoint “as an admin with a token”. However the private fields are not included in the response as they should be per the documentation.

When making the fields non-private ; they are included.

What does your API call look like?

def retrieve_activity_data(endpoint, headers, start_date, end_date, club):
activity_list =
cursor = 0 # Start at the first record
limit = 100

while True:
    params = {'cursor': cursor, 'limit': limit}
    if start_date and end_date:
        params['StartDate_gte'] = start_date
        params['EndDate_lte'] = end_date
    response = requests.get(endpoint, headers=headers, params=params).json()


    if 'response' not in response:
        print(f"Cursor: {cursor}, Limit: {limit}, No 'response' in the JSON returned from {endpoint} "
              f"with params {params}")
        break

    activities = response['response']['results']
    remaining = response['response']['remaining']

    if not activities:
        print(f"Cursor: {cursor}, Limit: {limit}, Activities are empty")
        break

    filtered_activities = [activity for activity in activities if activity.get('StartDate') is not None and
                           activity.get('RegisteredTime') is not None and activity.get('Club') == club]
    print(f"Cursor: {cursor}, Limit: {limit}, Total activities: {len(activities)}, "
          f"Filtered activities: {len(filtered_activities)}")

    activity_list.extend(filtered_activities)

    if remaining == 0:
        break
    else:
        cursor += len(activities)  # Move the cursor to the position of next result

print(activity_list)
return activity_list

Where are you providing the authentication / admin token? That’s the relevant part :slight_smile:

headers = {
“Authorization”: f"Bearer xxxxxxxxxxxxxxxxxxxx",
“Content-Type”: “application/json”,
}

I guess this is what you mean :slight_smile:

1 Like

Hmmm, looks good to me :man_shrugging: Other things might be to check you’re calling the test version, and to triple check your admin API key is valid (though I think Bubble returns an error if it’s not)

I have worked with this API for a long time so and it used to work.
I have triple checked the API Key and I know I am calling the version-test endpoint.

This topic was automatically closed after 14 days. New replies are no longer allowed.