Jon Crump
Posts: 0
Joined: Tue Dec 11, 2012 8:34 pm

YouTrack rest API

Trying to build an app using the YouTrack rest API, the service works as tested in the builder, when I come to run in it the browser, it returns a failed response, however using the inspector in Chrome, I can see the call was successful (status code 200) with a little green icon. Why is the successful call interpreted as a failure?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

YouTrack rest API

Hello! Could you send us your app link or clarify how we can define the service to test.

Jon Crump
Posts: 0
Joined: Tue Dec 11, 2012 8:34 pm

YouTrack rest API

This is my project:
http://project.tiggzi.com/project/93f...
Username: rest_api_user
Password: VMPGroup1234

And youtrack documentation on the login call:
http://confluence.jetbrains.net/displ...

Thanks for your help

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

YouTrack rest API

Thank you. We'll test

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

YouTrack rest API

Hello! In settings please set Data type to xml instead of json.

Jon Crump
Posts: 0
Joined: Tue Dec 11, 2012 8:34 pm

YouTrack rest API

Thanks for your help, that part is working now.

So when I login a cookie is returned which I need for the next step, this isn't part of the XML response though, how can I capture this to a Local Storage Variable?
I created a parameter in the response and mapped it to a Local Storage Variable, but it's always empty as the cookie is in the header not in the XML response.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

YouTrack rest API

Read the cookie value with JavaScript

Jon Crump
Posts: 0
Joined: Tue Dec 11, 2012 8:34 pm

YouTrack rest API

Sounds simple, I tried using Jquery code to access the cookie.
($.cookie) but that doesn't work.
I tried to include the Jquery cookie plugin as a JavaScript file but that causes errors too. (https://github.com/carhartl/jquery-co...)
Seems like that could be a useful library to have included.

Can you offer any more assistance on the JavaScript and the best place to put it? Currently on the completed event of the service.

Jon Crump
Posts: 0
Joined: Tue Dec 11, 2012 8:34 pm

YouTrack rest API

So I can read the cookies for the page, but it seems it's different to read the cookies returned from the rest api, that they are separate.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

YouTrack rest API

To make your service send and get Cookie while HTTP request use "Run Javascript" instead of "Invoke Service"

restservice1.execute({xhrFields: {
withCredentials: true
}})

restservice1 - name of data sourse component in "Data" tab
This parameter withCredentials: true will allow send and get Cookie automatically

Return to “Issues”