Connection error: “org.jsoup.UnsupportedMimeTypeException: Unhandled content type”

混江龙づ霸主 提交于 2019-11-30 07:58:00

Use ignoreContentType() (see doc here):

String myURL = "http://www.rfi.ro/podcast/emisiune/174/feed.xml";
Document pod = Jsoup.connect(myURL).ignoreContentType(true).get();
Vipul Jurel
// Initialize UnSupportedMimeTypeExeception class 
UnsupportedMimeTypeException mimeType = new UnsupportedMimeTypeException("Hey this is Mime",  "application/json", "http://dictionary.cambridge.org/dictionary/english/reality");
String mime = mimeType.getMimeType();

Document doc = Jsoup.connect("https://translate.google.com/translate_a/single?client=t&sl=en&tl=hi&hl=en&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&source=bh&ssel=0&tsel=0&kc=1&tk=2546.416541&q=consume")
    .requestBody("JSON")
    .header("Content-Type", mime)
    .cookies(response.cookies())
    .ignoreContentType(true)
    .post();
System.out.println(doc);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!