 <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
		<channel>
			<title>Intervals Forum - Java servlet and API response</title>
			<lastBuildDate>Thu, 23 May 2013 22:37:02 -0700</lastBuildDate>
			<link>http://www.myintervals.com/forum/</link>
			<description> Intervals Community &amp; Support</description>
			<generator>Lussumo Vanilla 1.1.10</generator>
			<atom:link href="http://www.myintervals.com/forum/discussion/633/java-servlet-and-api-response/?Feed=RSS2" rel="self" type="application/rss+xml" />
            <ttl>1800</ttl>
			<item>
		<title>Java servlet and API response</title>
		<link>http://www.myintervals.com/forum/discussion/633/#Comment_1977</link>
		<guid isPermaLink="false">http://www.myintervals.com/forum/discussion/633/#Comment_1977</guid>
		<pubDate>Fri, 23 Jul 2010 06:52:37 -0700</pubDate>
		<dc:creator>pennywise</dc:creator>
		<description>
			<![CDATA[Hi all, I'm trying to make a simple jquery script that send data to a java servlet, that will send request to myintervals, retrieve the response and send this one to the jquery script. So, the problem is the myinterval's response:<br /><br />&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br /><br />&lt;intervals personid=&quot;59348&quot; status=&quot;Bad Request&quot; code=&quot;400&quot;&gt;&lt;error&gt;&lt;code&gt;17&lt;/code&gt;&lt;message&gt;Parameter not recognized&lt;/message&gt;&lt;verbose&gt;&lt;item&gt;Unable to parse PUT/POST input. Please check your XML/JSON for validity and well-formedness.&lt;/item&gt;&lt;/verbose&gt;&lt;/error&gt;&lt;/intervals&gt;<br /><br />The request is done by servlet, in this way:<br /><br />protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException<br />	{<br />		HttpURLConnection my = null;<br />		URL myint = new URL(  -- query url  --);<br />		<br />		<br />		my = (HttpURLConnection)myint.openConnection();<br />		my.setRequestMethod(&quot;POST&quot;);<br />		my.addRequestProperty(&quot;Host&quot;, &quot;api.myintervals.com&quot;);<br />	        my.addRequestProperty(&quot;Accept&quot;, &quot;application/xml&quot;);<br />	        my.addRequestProperty(&quot;Content-type&quot;, &quot;application/json&quot;);<br />	        my.addRequestProperty(&quot;Authorization&quot;, &quot;Basic M2k1NnhzY3EzOG86WA==&quot;);<br />	        InputStream is = my.getInputStream();<br />	        BufferedReader in = new BufferedReader(new InputStreamReader(is));<br />		String inputLine;<br />		while ((inputLine = in.readLine()) != null) {<br />		    resp.getWriter().println(inputLine);<br />		}<br />		//resp.getWriter().println(myint);<br />		in.close();<br />		<br />	}<br /><br />With this i'm trying, with POST, to insert a new time object...what's wrong? I don't understand the error message!<br />If I try to retrieve information with GET, with the same java class, it works!<br />I hope you can help me, thx!<br /><br />ps: sorry for my english..<br />ppss: maybe this forum got problem with rich text? I can't set [CODE] or similar tag in this post...]]>
		</description>
	</item>
	<item>
		<title>Java servlet and API response</title>
		<link>http://www.myintervals.com/forum/discussion/633/#Comment_1978</link>
		<guid isPermaLink="false">http://www.myintervals.com/forum/discussion/633/#Comment_1978</guid>
		<pubDate>Fri, 23 Jul 2010 10:42:34 -0700</pubDate>
		<dc:creator>cameron</dc:creator>
		<description>
			<![CDATA[Hey pennywise,<br /><br />My Java knowledge is not very fresh so please bear with me. It looks like you're not sending any data to the server to create a new time object. In your code you've set Content-type to application/json, so you need to be sending JSON formatted data to the server. The following URL shows how to format your data (the example is in XML) when making a request:<br /><br />http://www.myintervals.com/api/resource.php?r=time<br /><br />The following URL contains an example of how to format your request to make a POST request using JSON data:<br /><br />http://www.myintervals.com/api/examples.php<br /><br />I've done a little bit of research on doing this in Java and this page looks like a good place to start:<br /><br />http://developers.sun.com/mobility/midp/ttips/HTTPPost/<br /><br />Particularly, it looks like you need to be using an OutputStream to pass POST data to the server. After &quot;my.addRequestProperty(&quot;Authorization&quot;, &quot;Basic M2k1NnhzY3EzOG86WA==&quot;);&quot; I would add something like the following:<br /><br />OutputStream os = my.openOutputStream();<br />os.write( -- JSON encoded data -- );<br /><br />Also, if you if you are using an important account (as opposed to a sandbox account), be sure to change your API token now that the base64 encoded version has been posted to this public forum.<br /><br />Hope this information helps.<br /><br />Cameron Brooks<br />Pelago]]>
		</description>
	</item>
	<item>
		<title>Java servlet and API response</title>
		<link>http://www.myintervals.com/forum/discussion/633/#Comment_1979</link>
		<guid isPermaLink="false">http://www.myintervals.com/forum/discussion/633/#Comment_1979</guid>
		<pubDate>Mon, 26 Jul 2010 01:20:14 -0700</pubDate>
		<dc:creator>pennywise</dc:creator>
		<description>
			<![CDATA[Thank you, now it works!<br /><br />In detail, if someone else need, the code is<br /><br />(...)<br />my.setDoOutput(true); //this to allow URL Connection to send output<br />OutputStreamWriter osw = new OutputStreamWriter(my.getOutputStream());<br />osw.write( /* JSON Content */);<br />(...)<br /><br />For the token, no problem about it, I'm using a free account for testing purpose, but thanks for your advice.<br /><br />Thank you again, regards!]]>
		</description>
	</item>
	
		</channel>
	</rss>