REST API via PHP
I'm attempting to access the YouTrack REST API via PHP-initiated posts, instead of from Javascript and I'm effectively going no where.
Does anyone have a working example of logging in and then creating a new issue? I can get the login to work correctly but then I can't get it to correctly re-use the session that the login returns.
Does anyone have a working example of logging in and then creating a new issue? I can get the login to work correctly but then I can't get it to correctly re-use the session that the login returns.
Please sign in to leave a comment.
Thank you for your request.
Actually, that's more about PHP then our REST API. However, I guess you may provide us with your code sample, and YouTrack users or someone from our team will help you.
Thank you.
<?php $url = 'http://path_to_my_youtrack.net/rest/user/login'; $data = array('login'=>'MyLogin', 'password'=>'somePassword'); // use key 'http' even if you send the request to https://... $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data), ), ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); var_dump($result); echo '<br><br>'; var_dump($http_response_header);The result is something like:
I've tried to do a few things with either (or both) of the Set-Cookie response headers...but without much success. Obviously the login is successful...but the problem is how to do the next POST request which will - say - create a new issue somewhere.