Java vs REST API. Need Help

Hi. I want to syncronize issues from redmine to YouTrack.

With API i'm get all issues from youtrack, all issues from redmine and for all new issues from redmine create new issue in YouTrack

Project in java

step 1
CookieStore cYouTrack = getCookieYoutrack(yBaseUrl, yLogin, yPass);

public static CookieStore getCookieYoutrack(String baseurl, String login, String password) throws Exception {
        HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(baseurl + "/rest/user/login");
        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
CookieStore cookieStore = ((DefaultHttpClient) httpClient).getCookieStore();

// get xml with issues
String xmlYouTrack = getYouTrackIssues(yBaseUrl, cYouTrack);
            String xmlRedmine = getRedmineIssues(rBaseUrl, rKey, rProject);

private static String getYouTrackIssues(String baseurl, CookieStore c) throws Exception {

        String url = baseurl + "/rest/export/Task/issues?10";

        HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet(url);

        // add request header
        ((DefaultHttpClient) client).setCookieStore(c);

IssueSync(xmlYouTrack, xmlRedmine, cYouTrack);

public static void IssueSync (String xmlYouTrack, String xmlRedmine, CookieStore cookie) {
if (!youtrackids.contains(((Node) fstNm.item(0)).getNodeValue())) {
putYouTrackIssue(subject, description, author, cookie);

public static void putYouTrackIssue(String subject, String description, String author, CookieStore cookie){
        String desc = description + "\n Автор:"+author;
        String url = yBaseUrl + "/rest/issue?Task&"+ URLEncoder.encode(subject)+"&"+URLEncoder.encode(desc);
        HttpClient client = new DefaultHttpClient();
        HttpPut request = new HttpPut(url);
        //response = client.execute(httppost, localContext);
        // add request header
        ((DefaultHttpClient) client).setCookieStore(cookie);

        HttpResponse response = null;
        try {
            response = client.execute(request);
        } catch (IOException e) {

When i'm send PUT request, i'm get 403. In logs: You do not have permissions to Создание задач, or project [null] does not exist. You do not have permissions to Создание задач, or project [null] does not exist.
 at sun.reflect.GeneratedMethodAccessor363.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(
 at java.lang.reflect.Method.invoke(
 at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(

Why the GET method return me issues, PUT - no created...
1 comment
question closed.

wrong url. Work url: String url = yBaseUrl + "/rest/issue?project=Task&summary="+ URLEncoder.encode(subject)+"&description="+URLEncoder.encode(desc);

Please sign in to leave a comment.