On Tue, Jul 20, 2010 at 4:12 AM, Zachariah Young <[email protected]> wrote:
> Where should I be setting the Content Type when I'm posting and XML string?
>
> HttpPost httppost = new HttpPost("http://localhost:8080/REST");
> // Make sure the server knows what kind of a response we will accept
> httppost.addHeader("Accept", "text/xml");
>
this is the right place to set the header.
> // Also be sure to tell the server what kind of content we are sending
> httppost.addHeader("Content-Type", "application/xml");
>
you technically could set this header but it is normally not a valid request
header. "Content-Type" is used in http response rather than request.
>
> or
>
> StringEntity stringEntity = new
>
> StringEntity("<printparamaters><request>1</request></printparamaters>","UTF-8");
> stringEntity.setContentType("application/xml");
>
>
i don't think the entity content type will affect the http request headers
at all.
regards,
mingfai