AbdFatah / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 0 forks source link

Error with utf8 characters and POST requests (used by Google's own IOS Library) #207

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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). 

Original issue reported on code.google.com by eduardos...@gmail.com on 9 May 2012 at 7:56

GoogleCodeExporter commented 9 years ago
Duplicate of #132

http://code.google.com/p/analytics-issues/issues/detail?id=132

Original comment by eduardocereto on 28 May 2012 at 5:47

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi @eduardocereto.. this might be a similar issue, but it's not necessarily the 
same thing. Thanks for linking to that one anyway, glad to know others are also 
having problems like this!

The issue here happens when posting data, as the GA iOS API does. I was able to 
use filters passing the exact data as above when doing GETs using the GA API 
playground, but with POSTs thru the API it fails. 

Original comment by eduardos...@gmail.com on 28 May 2012 at 5:53

GoogleCodeExporter commented 9 years ago
I tried all possible ways to get it working through the explorer API and I 
couldn't. So I queried the API directly to see if I could make any query with 
accented filters go through. I failed. I tried different types of quotes, 
double qoutes, tripple quotes, quotting everything but the accented word. 
Escapgin everything, not scaping anything, escaping everything but the word, 
... nothing works.

Could you post a query that has utf8 chars and works on the API but not with 
the iOS library?

From my point of view this bug seems to be on the REST api and not on any 
specific client library. As I said even querying the api directly without the 
use of any library I was not able to make it work.

Original comment by eduardocereto on 28 May 2012 at 6:33

GoogleCodeExporter commented 9 years ago
Using this I was able to properly filter data with special chars: 
http://ga-dev-tools.appspot.com/explorer/

For example, try setting the filter to "ga:Region==Baden-Württemberg" (no 
quotes). It fails above, like I mentioned in the bug, but I can successfully 
run it on that site. The site uses GETs instead of POSTs. 

Original comment by eduardos...@gmail.com on 28 May 2012 at 6:48

GoogleCodeExporter commented 9 years ago
I got a reply from a Google engineer at some point saying that POSTs are not 
technically supported, but that's what the Google's official iOS library uses. 
Fun stuff.

Original comment by eduardos...@gmail.com on 28 May 2012 at 6:49

GoogleCodeExporter commented 9 years ago
This was finally fixed. My app started working correctly all of a sudden this 
morning. Thanks Google!

Original comment by eduardos...@gmail.com on 31 May 2012 at 5:09

GoogleCodeExporter commented 9 years ago

Original comment by api.pe...@gmail.com on 31 May 2012 at 5:13