I create issues from a corporate site with JIRA REST API.
Creating everything under the administrator or agent, everything works. But creating a normal user (LDAP), there is a problem.
LDAP is configured correctly. Users in the system are working. Can there be a problem with access rights or system settings? I think I set everything right. Where to look?
<div id="wrapper">
<h1>Create Issue</h1>
<form id="create-form">
Summary: <input type="text" name="summary" id="summary" value=""/>
Description: <input type="text" name="description" id="description" value="" />
Issue Type: <input type="text" name="type" id="type" value=""/>
Username: <input type="text" name="user" id="user" value=""/>
Password: <input type="password" name="pass" id="pass" value=""/>
<input type="button" id="button" value="Create Issue"/>
</form>
</div>
<script>$('#button').click(function() {
$.ajax({
type: "POST",
url: "jiraapi.php",
data: $('#create-form').serialize(),
success: function(data){
alert(data);
},
dataType: "html"
});
});</script>
/**
<?php
$base64_usrpwd = base64_encode($_POST['user'].':'.$_POST['pass']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost:8080/rest/api/2/issue/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Authorization: Basic '.$base64_usrpwd));
$arr['project'] = array( 'key' => 'TP');
$arr['summary'] = $_POST['summary'];
$arr['description'] = $_POST['description'];
$arr['issuetype'] = array( 'name' => $_POST['type']);
$json_arr['fields'] = $arr;
$json_string = json_encode ($json_arr);
curl_setopt($ch, CURLOPT_POSTFIELDS,$json_string);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>
Under the administrator I get an alert with the data and the issue is created.
Under LDAP users, the response is empty, issue is not created, alert comes empty.
If login / password is not valid, then displays error 401
Hello,
Are you sure that the user from LDAP has permissions to create an issue it the project?
I usually experiment with REST API Browser plugin first. You can login under the user from LDAP to Jira and try to execute same request using the plugin. If everything is fine, then the problem is in your code. If not, then there will be the error.
That is the link for the plugin. It is free
https://marketplace.atlassian.com/plugins/com.atlassian.labs.rest-api-browser/server/overview
I never had a problem with Ldap users without a reason (Jira setups or code)
Having entered JIRA under the user LDAP, it is possible to create and view issues in the project. Using REST API, under LDPA user, create a issues does not work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you sure that response message is empty? What is response status?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No Response message.Console message like:
XHR finished loading: POST "http://..."
l.cors.b.crossDomain.send
n.extend.ajax
(anonymous function)
n.event.dispatch
r.handle
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not familiar much with php, but Atlassian usually returns JSON as a response. You need to print it to console. I could give you an example in Java but I guess it will not make sense.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the problem is that there is a bug in the script or when processing the validation of the login. Because response and does not return anything, it generally does not. Or the problem in access rights
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try to use POST /rest/auth/1/session and see if you are successfully connected
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.