[eluser]jakelehner[/eluser]
Does anyone have any tips on passing in XML to Phil's REST server so it will be interpreted as an array during an XML POST?
I use this library fairly extensively and it's been great so far. I can't seem to figure out how to pass in an array using a Chrome-based REST client. If I'm using Phil's CI REST client, it's fine. But the issue comes in when using a stand-alone rest client so I can easily change the request XML during testing.
Take the following hypothetical example of adding tags to a document. Not the best example, but it works for this purpose.
The goal here is to have $this->post('tags') to be an array once the request is received.
The following does not work:
Code:
<xml>
<docID>123</docID>
<title>something awesome</title>
<tags>
<tag>one</tag>
<tag>two</tag>
<tag>three</tag>
</tags>
</xml>
That results in:
Code:
Array
(
[docID] => 123
[title] => something awesome
[tags] => Array
(
[tag] => Array
(
[0] => one
[1] => two
[2] => three
)
)
)
Then the following throws a parse error:
Code:
<xml>
<docID>123</docID>
<title>something awesome</title>
<tags>
<0>one</0>
<1>two</1>
<2>three</2>
</tags>
</xml>
This next one works, but seems messy and counter intuitive:
Code:
<xml>
<docID>123</docID>
<title>something awesome</title>
<tags>one</tags>
<tags>two</tags>
<tags>three</tags>
</xml>
That results in:
Quote:Array
(
[docID] => 123
[title] => something awesome
[tags] => Array
(
[0] => one
[1] => two
[2] => three
)
)
Any suggestions?