You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by sunitha yellasinganamala <su...@gmail.com> on 2010/01/07 01:41:27 UTC

Missing start boundary error while using PostMethod and MultipartRequestEntity

Hi All,

I am using apache commons httpClient PostMethod in conjunction with
MultipartRequestEntity to upload a file.
I am getting a 500 status code and when I print the Response Body I see the
following error:
" javax.ws.rs.WebApplicationException:
org.jvnet.mimepull.MIMEParsingException: Missing start boundary
    at
com.sun.jersey.multipart.impl.MultiPartReader.readFrom(MultiPartReader.java:203)
....
"

Can anyone provide any pointers on why this is cause?

Here is how my code looks like:
            HttpClient client = new HttpClient();
            PostMethod method = new PostMethod(url);
           method.addRequestHeader("Content-Type", "multipart/form-data");
           method.addParameter("name", "somename here");

        try {
            Part[] parts = {
                    new StringPart("file","workflow.xml"),
                    new FilePart(targetFile.getName(), targetFile ,
"application/octet-stream","") };
            method.setRequestEntity(new MultipartRequestEntity(parts,
method.getParams()));

            } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
int statusCode = client.executeMethod(method);



Thanks
Sunitha

Re: Missing start boundary error while using PostMethod and MultipartRequestEntity

Posted by Oleg Kalnichevski <ol...@apache.org>.
sunitha yellasinganamala wrote:
> Hi Oleg,
> 
> I tried to use 4.1 but looks like it is not there on maven repository. I
> used mvn to get the latest version and apparently could only find 3.1 in mvn
> repository.
> I understand that I have another option of downloading the jar and add to
> classpath manually.
> Let me know if it is already available on mvn repo and the dependencies if
> it is.
> 

HttpClient 4.x is certainly available in the official maven repository. 
4.1 is still considered alpha, so look for 4.1-alpha1. 4.0.1 is stable 
and production ready:

http://repo1.maven.org/maven2/org/apache/httpcomponents/httpclient/

Hope this helps

Oleg

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Missing start boundary error while using PostMethod and MultipartRequestEntity

Posted by sunitha yellasinganamala <su...@gmail.com>.
Hi Oleg,

I tried to use 4.1 but looks like it is not there on maven repository. I
used mvn to get the latest version and apparently could only find 3.1 in mvn
repository.
I understand that I have another option of downloading the jar and add to
classpath manually.
Let me know if it is already available on mvn repo and the dependencies if
it is.

Thanks
Sunitha

On Thu, Jan 7, 2010 at 4:20 AM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Wed, 2010-01-06 at 16:41 -0800, sunitha yellasinganamala wrote:
> > Hi All,
> >
> > I am using apache commons httpClient PostMethod in conjunction with
> > MultipartRequestEntity to upload a file.
> > I am getting a 500 status code and when I print the Response Body I see
> the
> > following error:
> > " javax.ws.rs.WebApplicationException:
> > org.jvnet.mimepull.MIMEParsingException: Missing start boundary
> >     at
> >
> com.sun.jersey.multipart.impl.MultiPartReader.readFrom(MultiPartReader.java:203)
> > ....
> > "
> >
> > Can anyone provide any pointers on why this is cause?
> >
>
> For your own good consider upgrading to HttpClient 4.0.1 HttpClient 3.x
> is nearing end of life. I, for one, have no interest supporting it
> anymore.
>
> Oleg
>
>
> > Here is how my code looks like:
> >             HttpClient client = new HttpClient();
> >             PostMethod method = new PostMethod(url);
> >            method.addRequestHeader("Content-Type",
> "multipart/form-data");
> >            method.addParameter("name", "somename here");
> >
> >         try {
> >             Part[] parts = {
> >                     new StringPart("file","workflow.xml"),
> >                     new FilePart(targetFile.getName(), targetFile ,
> > "application/octet-stream","") };
> >             method.setRequestEntity(new MultipartRequestEntity(parts,
> > method.getParams()));
> >
> >             } catch (FileNotFoundException e) {
> >             // TODO Auto-generated catch block
> >             e.printStackTrace();
> >         }
> > int statusCode = client.executeMethod(method);
> >
> >
> >
> > Thanks
> > Sunitha
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: Missing start boundary error while using PostMethod and MultipartRequestEntity

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2010-01-06 at 16:41 -0800, sunitha yellasinganamala wrote:
> Hi All,
> 
> I am using apache commons httpClient PostMethod in conjunction with
> MultipartRequestEntity to upload a file.
> I am getting a 500 status code and when I print the Response Body I see the
> following error:
> " javax.ws.rs.WebApplicationException:
> org.jvnet.mimepull.MIMEParsingException: Missing start boundary
>     at
> com.sun.jersey.multipart.impl.MultiPartReader.readFrom(MultiPartReader.java:203)
> ....
> "
> 
> Can anyone provide any pointers on why this is cause?
> 

For your own good consider upgrading to HttpClient 4.0.1 HttpClient 3.x
is nearing end of life. I, for one, have no interest supporting it
anymore.

Oleg


> Here is how my code looks like:
>             HttpClient client = new HttpClient();
>             PostMethod method = new PostMethod(url);
>            method.addRequestHeader("Content-Type", "multipart/form-data");
>            method.addParameter("name", "somename here");
> 
>         try {
>             Part[] parts = {
>                     new StringPart("file","workflow.xml"),
>                     new FilePart(targetFile.getName(), targetFile ,
> "application/octet-stream","") };
>             method.setRequestEntity(new MultipartRequestEntity(parts,
> method.getParams()));
> 
>             } catch (FileNotFoundException e) {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>         }
> int statusCode = client.executeMethod(method);
> 
> 
> 
> Thanks
> Sunitha



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org