android - 415 Unsupported Media Type for XML Post Rest API -


i trying request rest post api xml string getting following error response.

<?xml version="1.0" encoding="utf-8" standalone="yes"?> <apierrors>        <apierror>               <errormessage>415 unsupported media type - null</errormessage>        </apierror> </apierrors> 

i don't understand why happening. set content-type , header also.

please take @ code.

string xmlstring = "<contact>"                                 +"<name>sandeep</name>"                                 +"<title>mr.</title>"                                 +"<address>india</address>"                                                                  +"</contact>";                    try {                 stringentity se = new stringentity(xmlstring);                 httppost httprequest = new httppost("http://abc:xyz123@000.000.000.00:8080/aaa/sample/feed/000001");                 httprequest.setheader("content-type","application/soap-xml;charset=utf-8");                 httprequest.setheader("accept","text/plain");                  httprequest.setentity(se);                 httpclient httpclient = new defaulthttpclient();                 httpresponse httpresponse;                 httpresponse = httpclient.execute(httprequest, new basichttpcontext());                  finalres = inputstreamtostring(httpresponse.getentity().getcontent())                             .tostring(); 

please give me hint or reference.

did try without charset="utf-8"?

(i couldn't leave comment due low reputation)


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -