Encoding issue when using POST with v3 API

124 views
Skip to first unread message

Eduardo Scoz

unread,
Apr 23, 2012, 12:10:13 PM4/23/12
to google-analytics...@googlegroups.com
Hi guys,

It seems like I was finally able to understand exactly a problem that is happening to the new v3 API when passing data in the body of a POST request (used by the iOS library). 

Here's the problem: the API cannot understand UTF8 characters passed in filters, like the following request. The data always comes back as empty (no errors).

{
    "method": "analytics.data.ga.get",
    "id": "gtl_17",
    "jsonrpc": "2.0",
    "params": {
        "end-date": "2012-04-22",
        "ids": "ga:MYID",
        "filters": "ga:Region==Baden-Württemberg",
        "metrics": "ga:visits, ga:pageviews, ga:visitBounceRate, ga:pageviewsPerVisit",
        "start-date": "2012-03-23",
        "sort": "-ga:visits",
        "dimensions": "ga:City"
    },
    "apiVersion": "v3"
}

If I remove the filter, or change it to "ga:Region==Germany" (no utf8 chars), it works correctly. But when I pass the ü it fails. It also fails for names that have commas in them, like the region of "Mariy El, Republic" in Russia. I tried to urlencode the filter to "ga:Region==Baden-W%C3%BCrttemberg", but it doesn't work either.


This works when doing normal GET requests (worked correctly on http://ga-dev-tools.appspot.com/explorer/?csw=1). 

Any ideas? This is causing a lot of frustration for some of the users of my app Quicklytics..

Thanks!

Eduardo Scoz



Nick

unread,
Apr 23, 2012, 1:17:10 PM4/23/12
to google-analytics...@googlegroups.com
Hi,

Our Core Reporting API is designed to only work with GET so I'm surprised you are making POST requests. It might be that POST is incorrectly encoding utf8 characters?

-Nick

Eduardo Scoz

unread,
Apr 23, 2012, 1:32:10 PM4/23/12
to google-analytics...@googlegroups.com
Hi Nick,

I'm using the Google Analytics SDK for iOS, which uses the GTMHTTPFetcher library to POST the request to Google. It works with POSTs out of the box, I haven't made any changes. Everything but this seems to work correctly.

From looking at the code, it uses UTF8 encoding correctly; I was able to decode the text just before it's sent to google and it appears correctly on the client.

Eduardo Scoz

unread,
May 4, 2012, 3:27:02 PM5/4/12
to google-analytics...@googlegroups.com
any chance somebody could look into this? It's still an issue..

Nick

unread,
Jun 1, 2012, 1:02:58 PM6/1/12
to google-analytics...@googlegroups.com
Hi,

We looked into it and we fixed it for you Eduardo.

See our most recent change log update for 2012-05: https://developers.google.com/analytics/community/export_changelog

-Nick

Eduardo Scoz

unread,
Jun 1, 2012, 1:04:19 PM6/1/12
to google-analytics...@googlegroups.com
Yup, I saw that update yesterday.. Thanks so much Nick/team! App works perfectly now.




--
You received this message because you are subscribed to the Google Groups "GA Data Export API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-analytics-data-export-api/-/wOce9BY5WCQJ.
To post to this group, send email to google-analytics...@googlegroups.com.
To unsubscribe from this group, send email to google-analytics-data-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-analytics-data-export-api?hl=en.

Reply all
Reply to author
Forward
0 new messages