NewXMLText := StringReplace(XMLText, #13#10, ' ', [rfReplaceAll, rfIgnoreCase]);
Tuesday, March 04, 2008
Beware of XML Content contain CRLF always cause problem with Google API
We may consume the Google API to post entry of event kind. Those entry are mostly encoded in XML content. It is a common habit for windows user to create the XML content in windows notepad.
If we pass the XML content from notepad directly to the Google API, we will mostly encounter error such as HTTP 400 Bad Request. The reason is simple but yet difficult to discover. CRLF (0x0D 0x0A) is default line separator in windows operating system. The Google API or perhaps the content type we specify in the HTTP request header is application/atom+xml may not recognize the CRLF and cause the HTTP 400 Bad request error.
Always remember to well form the XML content before consume the API services. For example, replace all CRLF to a space character:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment