1

I have a xml payload which I am input to a webresource PUT . I am getting a error 400 bad request my payload:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<value>100</value>
<name>a</name>

code :

Client client = Client.create();
WebResource webResource = client.resource("url");
String input ="<?xml version=\"1.0\" encoding=\"UTF-8\"?><value>100</value><name>a</name>";
ClientResponse res=webResource.webResource.type(MediaType.APPLICATION_XML).header("Content-Type","application-xml").put(ClientResponse.class,input);
codehacker
  • 381
  • 5
  • 15

1 Answers1

0

It's not valid XML. XML can only have a single root element. You have two, value and name. If you wrap it in a root element, then it would be valid

<data>
    <value>100</value>
    <name>a</name>
</data>

What exactly the root element name should be, I don't know. It's up to the server.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720