8
votes

I'm looking for a way to fetch Media Insights metrics in Instagram Graph API (https://developers.facebook.com/docs/instagram-api/reference/media/insights) with a nested query based on the userId, even when a client switched from a Personal to a Business account.

I use this nested query to fetch all the data I need : https://graph.facebook.com/v3.2/{userId}?fields=followers_count,media{media_type,caption,timestamp,like_count,insights.metric(reach, impressions)} (this part causes the error: insights.metric(reach, impressions) - it works however for an account that has always been a Business one)

However, because some media linked to the userId were posted before the user switched to a Business account, instead of returning the data only for the media posted after, the API returns this error:

{
    "error": {
        "message": "Invalid parameter",
        "type": "OAuthException",
        "code": 100,
        "error_data": {
            "blame_field_specs": [
                [
                    ""
                ]
            ]
        },
        "error_subcode": 2108006,
        "is_transient": false,
        "error_user_title": "Media Posted Before Business Account Conversion",
        "error_user_msg": "The media was posted before the most recent time that the user's account was converted to a business account from a personal account.",
        "fbtrace_id": "Gs85pUz14JC"
    }
}

Is there a way to know, thru the API, which media were created before and after the account switch from Personal to Business? Or is there a way to fetch the date on which the account was switched?

The only way I currently see to get the data I need is to use the /media edge and query insights for each media until I get an error. Then I would get approximately the date I need. However, this is not optimized at all since we are rate limited to 200 calls per user per hour.

2

2 Answers

3
votes

I have the same problem.

For now, I'm Switch between queries (if first have error)

"userId"?fields=id,media.limit(100){insights.metric(reach, impressions)}

"userId"?fields=id,media.limit(100)

I show the user all insights in zero.

I don't know if they're the best alternative, like identify the time of conversion to business and get the post between this range of DateTime

2
votes

I got the same problem and solved it like this:

  • Use the nested query just like you did, including insights.metric
  • If the error appears, do another call without insights.metric - to at least get all other data

For most accounts, it works and there is no additional API call. For the rest, i just cannot get the insights and i have to live with it, i guess - until Facebook/IG fixes the issue.