<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Webdevotion.be &#187; httprequest</title>
	<atom:link href="http://www.webdevotion.be/blog/tag/httprequest/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdevotion.be/blog</link>
	<description>Trainer for the Flash Platform and iOS</description>
	<lastBuildDate>Tue, 01 Nov 2011 10:14:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to PUT xml to a REST interface with Basic Authentication</title>
		<link>http://www.webdevotion.be/blog/2008/12/12/how-to-put-xml-to-a-rest-interface-with-basic-authentication/</link>
		<comments>http://www.webdevotion.be/blog/2008/12/12/how-to-put-xml-to-a-rest-interface-with-basic-authentication/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 12:36:31 +0000</pubDate>
		<dc:creator>Webdevotion</dc:creator>
				<category><![CDATA[Air]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[assembla]]></category>
		<category><![CDATA[basic auth]]></category>
		<category><![CDATA[headers]]></category>
		<category><![CDATA[httprequest]]></category>
		<category><![CDATA[httpservice]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[urlloader]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://webdevotion.be/blog/?p=220</guid>
		<description><![CDATA[Well, this thing got me going for a couple of hours before things worked out. Using HTTPService did not seem to be the way to go. Long story short: URLRequest to the rescue! // basic authentication var encoder : Base64Encoder &#8230; <a href="http://www.webdevotion.be/blog/2008/12/12/how-to-put-xml-to-a-rest-interface-with-basic-authentication/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, this thing got me going for a couple of hours before things worked out.  Using HTTPService did not seem to be the way to go.  Long story short: URLRequest to the rescue!</p>
<p><img src="http://webdevotion.be/blog/wp-content/xml-rest-api.jpg" alt="" title="xml-rest-api"  width="600" class="alignnone size-full wp-image-225" /></p>
<p><span id="more-220"></span><br />
<code><br />
// basic authentication<br />
var encoder : Base64Encoder = new Base64Encoder();<br />
encoder.encode(username + ":" password);<br />
// send xml<br />
var header1:URLRequestHeader = new URLRequestHeader("Content-Type", "application/xml");<br />
// authenticate<br />
var header2:URLRequestHeader = new URLRequestHeader("Authorization", "Basic " + encoder.toString());<br />
// accept xml as response<br />
var header3:URLRequestHeader = new URLRequestHeader("Accept","application/xml");</p>
<p>var request:URLRequest = new URLRequest( urlToRestAPI );<br />
// mmm, maybe not necessary = allready in the headers<br />
request.contentType = "application/xml";<br />
// push the headers in the request<br />
request.requestHeaders.push(header1);<br />
request.requestHeaders.push(header2);<br />
request.requestHeaders.push(header3);</p>
<p>// put your xml in a string: &quot;&lt;ticket&gt;&lt;summary&gt;my summary&lt;/summary&gt;&lt;/ticket&gt;&quot;<br />
// generate an XML instance from the string<br />
var xml : XML = new XML( s );<br />
// put the xml in the request instance<br />
request.data = xml;<br />
// use PUT ( could depend on the API you are using, check the docs )<br />
request.method = "PUT";<br />
// use the loader to send the request<br />
var loader : URLLoader = new URLLoader( null );<br />
// wait for the complete event to do other amazing things<br />
loader.addEventListener(Event.COMPLETE,onTicketUpdated,false,0,true);<br />
// fire in the hole!<br />
loader.load( request );<br />
// take a deep breath and wait a sec<br />
// for the complete event to be triggered<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevotion.be/blog/2008/12/12/how-to-put-xml-to-a-rest-interface-with-basic-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

