But what happens when the user wants to have an xml stream in the metadata? For example when a bot is using the ESME api and wants to store additional material in the message? I was trying to duplicate the Twitter Annotations behavior: http://apiwiki.twitter.com/Annotations-Overview
On Sun, Jul 11, 2010 at 2:07 PM, Vassil Dichev <[email protected]> wrote: > Dick, sorry about the delay, I had no Internet access last week. No problems > > The problem with JSON you're experiencing is because the shell removes > quotation marks, as they are used to quote the message data so that > special characters like "&" are not interpreted by the shell. You can > try using single quotation marks around the posted string: > > curl -b headers -d > 'message=test70&metadata=<metadata>"meta":[{"place":{"place_type":"city","region":"CA+"}},{"song":{"artist":"Prince","songtitle":"Never+Let+Me+Down"}}]</metadata>' > http://localhost:8080/api2/user/messages > > This does work, but of course everything inside the metadata is > escaped according to XML rules, so the response will be something > like: > > <?xml version="1.0" encoding="UTF-8"?> > <api><message> > <id>16</id> > <date>Sun, 11 Jul 2010 11:15:19 UTC</date> > <source>api2</source> > <body>test70</body> > <metadata>"meta":[{"place":{"place_type":"city","region":"CA > "}},{"song":{"artist":"Prince","songtitle":"Never > Let Me Down"}}]</metadata> > <author><nickname>vdichev</nickname><id>1</id></author> > <tags></tags><replyto></replyto><conversation></conversation> > </message></api> > > > You are correct that currently only the text elements are extracted > from the metadata XML. I think this is the correct behaviour, > otherwise one could mess with the internal XML message representation > by putting in some of the used elements like <body>, <tags>, another > <metadata>, etc. Probably a workaround could be to somehow escape the > XML contained within the metadata. The problem is that apart from > escaping XML and quoting the shell, the string must also be > URL-encoded! So something like <a/> would probably turn to > "<a/>" and then urlencoded would become "%26lt;a/%26gt;". > > Cheers, > Vassil > > > On Wed, Jul 7, 2010 at 11:02 AM, Richard Hirsch <[email protected]> wrote: >> I'm been working on the use of metadata in api2 and have got it >> working but the problem is that 1) all "s are removed when using JSON >> (see below) or 2) all XML tags are removed when posting with XML. >> >> I assume that this problem is linked to the following code in Message.scala >> >> lazy val metadata: String = originalXml \ "metadata" text >> >> lazy val metaData: String = { >> val org = originalXml >> >> (org \ "metadata").map(_.text).first >> } >> >> Anyone have any idea what the problem is? >> >> There is also a JIRA item for thsi: >> https://issues.apache.org/jira/browse/ESME-242 >> >> D. >> >> >> ------------------------ >> >> curl -b headers -d "message=test70&metadata=<metadata>" >> meta":[{"place":{"place_type":"city","region":"CA+"}},{"song":{"artist":"Prince" >> ,"songtitle":"Never+Let+Me+Down"}}]</metadata>" >> http://localhost:8080/api2/user/ >> messages >> >> <?xml version="1.0" encoding="UTF-8"?> >> <api><message> >> <id>47</id> >> <date>Wed, 7 Jul 2010 07:57:03 UTC</date> >> <source>api2</source> >> <body>test70</body> >> <metadata>meta:[{place:{place_type:city,region:CA >> }},{song:{artist:Prince,song >> title:Never Let Me Down}}]</metadata> >> <author><nickname>bob1</nickname><id>1</id></author> >> <tags></tags><replyto></replyto><conversation></conversation> >> </message></api> >> >
