You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
This is the url I'm using: https://xxxx.atlassian.net/rest/api/latest/issue
and this is the payload I got from an example on the net, I only changed the project key:
{"fields":{"summary":"TEST SUMMARY","issuetype":{"name":"Bug"},"project":{"key":"ET"}}}
BTW, I got the project key from /project/search:
{
"total": 1,
"isLast": true,
"maxResults": 50,
"values": [{
"avatarUrls": {...},
"entityId": "...",
"isPrivate": false,
"uuid": "...",
"expand": "description,lead,issueTypes,url,projectKeys,permissions,insight",
"simplified": true,
"name": "...",
"self": "https://....atlassian.net/rest/api/2/project/10000",
"style": "next-gen",
"id": "10000",
"projectTypeKey": "software",
"key": "ET",
"properties": {}
}],
"self": "https://....atlassian.net/rest/api/latest/project/search?maxResults=50&startAt=0",
"startAt": 0
}
I also checked I have access to create issues using /mypermissions?permissions=CREATE_ISSUES
"CREATE_ISSUES": {
"havePermission": true,
"name": "Create Issues",
"description": "Ability to create issues.",
"id": "11",
"type": "PROJECT",
"key": "CREATE_ISSUES"
}
I followed the authentication tutorial here: https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-oauth-authentication/
... and based my code on the examples here: https://bitbucket.org/atlassianlabs/atlassian-oauth-examples/src/master/
Any ideas? Thanks :)
Dear @Etienne Sillon ,
if you try to change the project key of an entire Jira project, I doubt that this is implemented with REST. You need to do this within the UI.
If you want to change the issue key of a single issue, you need:
This is a "work-a-round". Unfortunately there is no MOVE rest endpoint yet implemented. See JRASERVER-71343 for a suggestion for Server. Its same in Cloud.
So long
Thomas
Hi Thomas,
Thank you very much for the reply. I'm not trying to change the project key, I'm just trying to create an issue in the project but I don't seem to be able to specify the correct key.
When I do .../project/search I get my project info including "key": "ET", so that's what I use to create the issue with .../issue with payload: {"fields":{"summary":"TEST SUMMARY","issuetype":{"name":"Bug"},"project":{"key":"ET"}}}
Cheers,
Etienne
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear @Etienne Sillon ,
sorry for misunderstanding you.
Your question is tagged as "cloud". In this case you do not specify the project key but it's id, instead.
"project": {"id": "10000"}
See more here.
So long
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thomas,
Thanks again for the reply. I had tried the project id as well but got the same result.
I did manage to create an issue by creating an API token and using the curl command as per the link you sent:
curl --request POST \
--url 'https://xxx.atlassian.net/rest/api/3/issue' \
--user 'xxxxx:xxxxx' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"update": {},
"fields": {
"summary":"TEST SUMMARY","issuetype":{"id":"10001"},"project":{"id":"10000"}
}
}'
Not sure why the exact same payload doesn't work through the Java client, even thought I can access the project and issues using it.
Anyway, all good, I'll use the API token version, thanks again!
Etienne
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Etienne Sillon hey i am having the same problem; via postman client everything is fine, but in java client i can't get it to work. Did you solve the problem in the end?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Raffaele Messina yep, this is the code I used:
/******************************************************************************************************/
public static void createIssue(String projectId, String issueTypeId, String summary, String description) {
String url = "https://xxxxx.atlassian.net/rest/api/latest/issue";
JSONObject payload = getCreateIssuePayload(projectId, issueTypeId, summary, description);
sendHttpPost(url, payload);
}
/******************************************************************************************************/
private static JSONObject getCreateIssuePayload(String projectId, String issueTypeId, String summary, String description) {
JSONObject ret = new JSONObject();
try {
JSONObject fieldsData = new JSONObject();
JSONObject projectData = new JSONObject();
projectData.put("id", projectId);
fieldsData.put("project", projectData);
fieldsData.put("summary", summary);
fieldsData.put("description", description);
JSONObject issueTypeData = new JSONObject();
issueTypeData.put("id", issueTypeId);
fieldsData.put("issuetype", issueTypeData);
ret.put("fields", fieldsData);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(ret.toString());
return ret;
}
/******************************************************************************************************/
public static String sendHttpPost(String url, JSONObject payload) {
System.out.println("sendHttpPost(): url=" + url);
String ret = "";
HttpClient httpclient = HttpClients.createDefault();
HttpPost post = new HttpPost(url);
post.addHeader("Accept" , "application/json");
post.addHeader("Content-Type" , "application/json");
post.addHeader("Authorization" , "Basic XXXXXXXXX");
try {
StringEntity payloadEntity = new StringEntity(payload.toString());
post.setEntity(payloadEntity);
HttpResponse response = httpclient.execute(post);
int code = response.getStatusLine().getStatusCode();
System.out.println("status=" + code);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(instream), 1);
try {
String line;
while ((line = bufferedReader.readLine()) != null) {
ret += line;
}
instream.close();
bufferedReader.close();
} finally {
instream.close();
bufferedReader.close();
}
}
} catch (Exception e) {
e.printStackTrace();
}
if(ret.length() == 0) {
ret = "I'm sorry, there was an error processing your request";
}
System.out.println("sendHttpPost(): ret=" + ret);
return ret;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Getting the exact same issue here. Our organization needs this to automate the creation of bugs.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could any share the payload getting the same 400 response code
This is my below payload JSON
payload = json.dumps(
{
"fields" : {
"project": {
"id":"10000"
},
"summary": "Create JIRA issue",
"issuetype": {
"id": "10001"
},
"parent": {
"key": "PM"
},
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "This is the description.",
"type": "text"
}
]
}
]
}
}
})
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.