Tuve un problema similar para xml. Solo pasando el error y la solución (versión editada de Jonathon).
Código:
HttpGet xmlGet = new HttpGet(xmlContent);
formato XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<employee>
<code>CA</code>
<name>Cath</name>
<salary>300</salary>
</employee>
error:
java.lang.IllegalArgumentException: Illegal character in path at index 0: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<contents>
<portalarea>CA</portalarea>
<portalsubarea>Cath</portalsubarea>
<direction>Navigator</direction>
</contents>
at java.net.URI.create(URI.java:859)
at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:69)
at de.vogella.jersey.first.Hello.validate(Hello.java:56)
Solución No exactamente perfecta: (error desapareció para esa instancia)
String theXml = URLEncoder.encode(xmlContent, "UTF-8");
HttpGet xmlGet = new HttpGet(theXml);
idea de lo que debería estar haciendo? Se acaba de borrar pasado, pero tuvo un problema al hacer esto
HttpResponse response = httpclient.execute(xmlGet);
Ver [? Cómo resolver este carácter ilegal excepción en ruta] (http://stackoverflow.com/questions/3753852/how- to-solve-this-exception-illegal-character-in-path) –
intente reemplazar los espacios con '% 20' – nothrow
Vea la solución general en http://stackoverflow.com/questions/749709/how-to-deal-with -the-urisyntaxexception/15570670 # 15570670 – GKislin