Error 400,content is not allowed in prolog

by jan » Sun, 07 Mar 2010 03:43:25 GMT


Sponsored Links
 I have tried the following code to create map in android but its
giving me Error
400:Content is not allowed in prolog.
Here is my code.

String feed ="<entry xmlns=' http://www.w3.org/2005/ 
Atom'>"+"<title>First Map Created</title>"+"<summary>Hey Hey
I Did it</summary>"+"</entry>";
URL   urlget = new URL(" http://maps.google.com/maps/feeds/maps/ 
myuserid/full");
                        HttpURLConnection conget =(HttpURLConnection)
urlget.openConnection();
                        conget.setRequestProperty("Content-Type",
"application/atom+xml");
                conget.setRequestProperty("Content-Length",
Integer.toString(feed.length()));
                conget.setRequestProperty("Authorization","GoogleLogin
auth="+authtok); // auth contains my authentication token.
                        conget.setDoOutput(true);
                        conget.setDoInput(true);
                     Log.d("setRequestMethod","POST");

                        conget.setRequestMethod("POST");
                     Log.d("conget","connect");

                     conget.connect();
                     Log.d("conget","responsecode");

                 OutputStream outputStream = conget.getOutputStream();
                 outputStream.write(feed.getBytes());
                 outputStream.close();
                 int responseCode1 = conget.getResponseCode();
                 Log.d("reponsecode",Integer.toString(responseCode1));
                InputStream inputStream;

                 if (responseCode1 == HttpURLConnection.HTTP_CREATED)
{
                   inputStream = conget.getInputStream();
                 } else {
                   inputStream = conget.getErrorStream();
                 }
                 byte[] array=new byte[1024];
                        inputStream.read(array,0,1024);
                        String result=new String(array);
                     Log.d("result",result);

I am able to retrieve the list of maps but could not create map.
Can anybody help what am doing wrong , looking forward for your
replies

Regards

--



Error 400,content is not allowed in prolog

by janaki » Fri, 12 Mar 2010 01:46:51 GMT


 Hi,

I have tried the following code to create map but its giving me Error
400:Content is not allowed in prolog.
Here is my code.

String feed ="<entry xmlns=' http://www.w3.org/2005/ 
Atom'>"+"<title>First Map Created by Janaki</title>"+"<summary>Hey Hey
I Did it</summary>"+"</entry>";
URL   urlget = new URL(" http://maps.google.com/maps/feeds/maps/ 
myuserid/full");
                        HttpURLConnection conget =(HttpURLConnection)
urlget.openConnection();
                        conget.setRequestProperty("Content-Type",
"application/atom+xml");
                conget.setRequestProperty("Content-Length",
Integer.toString(feed.length()));
                conget.setRequestProperty("Authorization","GoogleLogin
auth="+authtok); // auth contains my authentication token.
                        conget.setDoOutput(true);
                        conget.setDoInput(true);
                     Log.d("setRequestMethod","POST");

                        conget.setRequestMethod("POST");
                     Log.d("conget","connect");

                     conget.connect();
                     Log.d("conget","responsecode");

                 OutputStream outputStream = conget.getOutputStream();
                 outputStream.write(feed.getBytes());
                 outputStream.close();
                 int responseCode1 = conget.getResponseCode();
                 Log.d("reponsecode",Integer.toString(responseCode1));
                InputStream inputStream;

                 if (responseCode1 == HttpURLConnection.HTTP_CREATED)
{
                   inputStream = conget.getInputStream();
                 } else {
                   inputStream = conget.getErrorStream();
                 }
                 byte[] array=new byte[1024];
                        inputStream.read(array,0,1024);
                        String result=new String(array);
                     Log.d("result",result);

I am able to retrieve the list of maps but could not create map.
Can anybody help what am doing wrong , looking forward for your
replies

Regards

--


Sponsored Links


Other Threads

1. XML editor problem

Hi

  I am trying to create an xml file under "res/xml" folder.

  When an xml file is newly created in the "res/layout" folder, the
xml editor comes up with a neat GUI giving me options to choose
layout, view, etc.

  However, when I create an xml file under "res/xml" folder, no such
options are shown. I would like to create an xml for PREFERENCE (radio
button).

  Please let me know if I am going wrong somewhere?

Thanks.

-- 

2. Using Instrumentation for functional testing

I need to create functional tests in a context outside of a junit test
method.  I do have the ability to create a class that inherits from
one of the TestCase derived classes in android but I cannot create a
test method.  I was hoping to start the instrumentation and then call
methods to simulate user interaction.  I have been unable to find
examples that demonstrate this capability.  Does anybody have
experience with this?

Thanks

-- 

3. From one Tab change to another one

4. AppRank?

5. Free Heap to Small to Allocate Bitmap

6. Detect and pick up Gesture in a filled ListActivity

7. About to release first app to market.