I've been trying to login to JIRA using the Jsoup API, but it's not working for some reason.
I've tried to identify the username and password tags, but still no good.
Can someone please help me figure out what I am doing wrong?
public class test
{
public static void main(String[] args) throws IOException{
final String USER_AGENT = "\"Mozilla/5.0 (Windows NT\" +\n" +
" \" 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36\"";
String loginFormUrl = "https://jira.aciworldwide.com/login.jsp";
String loginActionUrl = "https://jira.aciworldwide.com/login.jsp";
String username = "jon@jon";
String password = "XXXXXX";
HashMap<String, String> cookies = new HashMap<>();
HashMap<String, String> formData = new HashMap<>();
Connection.Response loginForm = Jsoup.connect(loginFormUrl).method(Connection.Method.GET).userAgent(USER_AGENT).execute();
Document loginDoc = loginForm.parse(); // this is the document that contains response html
cookies.putAll(loginForm.cookies()); // save the cookies, this will be passed on to next request
formData.put("login", "Log In");
formData.put("os_username", username);
formData.put("os_password", password);
Connection.Response homePage = Jsoup.connect(loginActionUrl)
.cookies(cookies)
.data(formData)
.method(Connection.Method.POST)
.userAgent(USER_AGENT)
.execute();
System.out.println(homePage.parse().html());
}
}
If not JSoup, is there any other API available for the same?
Any help would be greatly appreciated!