taskadapter / redmine-java-api

Redmine Java API
Apache License 2.0
270 stars 163 forks source link

Error 404 in User.getCurrentUser() #327

Closed emiliogq closed 4 years ago

emiliogq commented 5 years ago

Hi,

I need this method but when I tried it in a Test java class it throws me a Not found exception:

`` import com.taskadapter.redmineapi.RedmineException; import com.taskadapter.redmineapi.RedmineManager; import com.taskadapter.redmineapi.RedmineManagerFactory; import com.taskadapter.redmineapi.UserManager;

public class Test {

public static void main(String[] args) {
    RedmineManager mgr = RedmineManagerFactory.createWithUserAuth("https://redmine.ice.csic.es", "privateuser","password");
    UserManager umgr = mgr.getUserManager();

    try {
        umgr.getCurrentUser();
    } catch (RedmineException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

} `` com.taskadapter.redmineapi.NotFoundException: Server returned '404 not found'. response body:<!DOCTYPE html>

Redmine 404 error

Page not found

The page you were trying to access doesn't exist or has been removed.

Back

The redmine version is 3.4.6

What's wrong?

Thanks in advance

emiliogq commented 5 years ago

It was caused by the missing last slash. The error message could be more specific.

alexeyOnGitHub commented 4 years ago

if a Redmine server responds with "404 - not found", the library cannot reliably detect if this is due to some items not found by the REST API, or the URL itself is not valid. there could be all kinds of web servers sitting in front of Redmine, and they can return arbitrary text . feel free to submit a PR with some docs / code samples if you think some URLs are not valid in sample code.