Search code examples
google-analyticsgoogle-analytics-apigoogle-analytics-sdk

Analytics API 2.4 returns invalid XML with 0x1F


I have some C# code communicating with Analytics API v2.4. This has been working for almost five years, but suddenly Analytics is returning malformed XML, starting with character 0x1F.

Method XmlReader.MoveToContent() throws System.Xml.XmlException with message:

' ', hexadecimal value 0x1F, is an invalid character. Line 1, position 1.

This was first noticed on 8 Aug 14:30 UTC. Four hours earlier this was not a problem.

I realize this is more a bug report than a question, still:

  • Has anyone else noticed this?
  • What do you do against this? In C# you can work around this by setting ReaderSettings.CheckCharacters to false but I don't know what other side effects this may cause.

Thanks!


Solution

  • I'm guessing that the response is being gzip compressed (gzip's header starts with 1f 8b) and you'll have to decompress it now.

    I'm not sure what changed, your code, your libraries or the analytics API.

    Sorry I'm not a C# expert and can't help you with the code.

    see https://en.wikipedia.org/wiki/Gzip#File_format