سؤال

I want to connect https url using Jsoup I followed How to connect via HTTPS using Jsoup??

But now I am getting

Exception in thread "main" org.jsoup.HttpStatusException: HTTP error fetching URL. Status=401, URL=myurl
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:435)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:410)
    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:164)
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:153)
    at FIndItNow.main(FIndItNow.java:27)

Any idea how to fix this ?

I am calling like

Document doc = Jsoup.connect(myurl).userAgent("Mozilla").get();
هل كانت مفيدة؟

المحلول

As error 401 says it is an UNAUTHORIZED request. It seems you need send some authentication headers in the request. Either you are not sending them or those are not correct.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top