i want to create an issue in JIRA by using the REST API provided by JIRA.
i am able to create a simple issue,
using this :
http://localhost:8080/rest/api/latest/issue
and data as follows:
{"fields":{"project":{"key": "TES"},"summary":"user name not showing validation message","description":"Hi validation is missing from user name","issuetype": {"name": "Bug"},"reporter":{"name":"BruceWayne"} }}
this is running fine.
now i want to add 3 custom fields while creating an issue. The custom fields are Authorname,
AuthorTag,AuthorID. how can i do this in rest api. what should i add in my data.
My sample data is as follows:-
{"fields":{"project":{"key": "TES"},"summary":"my bugs 5","description":"Hi","issuetype": {"name": "Bug"},
"customfield_10000":"roach#yahoo.com",
"customfield_10100":{"value":"abc"},
"reporter":{"name":"amit"},
"components": [{
"add" : {"name" : "abc"}
}],"priority": {
"id": "1"
}
}}
i want to use the names specified for customfields rather than customfield_XXXXX .
One way i think of is to hit the API after creating a simple issue ( using another API hit to get meta data as follows)
http://localhost:8080/rest/api/latest/issue/tes-79?expand=editmeta
and then do json parsing and again issue a put command to update the fields in same issue
but i was looking for a way to do it in single API hit (while creating an issue)
It should be just like setting any other field, but you have to use the field name "customfield_NNNNN" instead
I know that it is very late to answer this question, but then might help others if not the OP at this time of writing.
If you're in doubt about the create, then you could do something like this - Try a GET on an issue that you would rather create manually with the new parameters as well and then based on the output of the same you could then decide to update it with the new parameters with the new name or the old-fashioned customfield_xxx field.
Try a GET like this on cURL
curl -D- -u fred:fred -X GET -H "Content-Type: application/json" https://jira.fred.com/rest/api/2/issue/FRD-88651
Then you could possibly do a POST like how you've done earlier:
http://localhost:8080/rest/api/latest/issue
Related
we used to have three different JIRA projects, and merged them all into one new project, resulting in new IssueKeys for all issues involved.
Unfortunately, test automation uses the IssueKey to update the issue about test results (via SQL INSERT statement), and I try to avoid updating the list of IssueKeys in the suite.
I can think of two ways:
Addressing the issues by the old IssueKey. This seems to work in JIRA JQl search (issuekey=ISSUE-OLD finds the same issue as issuekey=ISSUE-NEW ), but not for the SQL INSERT statement.
Getting a list of pairs old-new IssueKey. For example, in JIRA under "activity" and "all", I can see entries that log the changes. Exporting tose worklogs might be a great help, but there might be other ways.
Thanks in advance,
Florian
I assume you're updating a test management db, not the Jira db (which would not be good)
You might also be interested in the moved_issue_key table which is where Jira stores the previous issue keys (e.g. ABC-123) and maps them to an issue id (the id in the jiraissue table)
you can use the curl api:
curl -D- -u user:password -X GET -H "Content-Type: application/json" https://url.com/rest/api/2/issue/ISSUE-OLD
The response will contain the key value as ISSUE-NEW with other details.
I cannot figure out if its possible to assign an ID from /survey_category when creating a new new survey via the API?
I noticed on surveymonkey.com when I create a new survey a POST request included a category_id but I can't find any info in the documentation. I've tried this:
curl -i -X POST -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveymonkey.net/v3/surveys -d '{"title":"My Survey", "category_id": "marketing"}'
No there isn't currently a way to assign a category to a survey. The categories from the endpoint /survey_categories are only for filtering templates from /survey_templates.
I don't believe surveys created from one of those templates remain tagged with that category. As of right now there is no "Survey tagging" functionality on SurveyMonkey - although I can see how it can be useful.
See this question for possible workarounds.
I would like to be able to add a flag to an issue via the Jira API. I was unable to find any documentation regarding this issue. Does anyone know how this works?
I've figured out how to do this, I'm not sure on the version of the API. I made a POST request to:
yourdomain /rest/greenhopper/1.0/xboard/issue/flag/flag.json
And in the body (replace JIRA-ISSUE with your issue key):
{"issueKeys":["JIRA-ISSUE"],"flag":true}
I hope this helps.
Here is the best answer I found.
https://answers.atlassian.com/questions/38062844/answers/38062897
There is a field called Flagged. It is a checkbox type field. There is a single value by default, Impediment. The field is checked for null status. If the field is null, the issue is not flagged. If the field is not null, the issue is flagged.
You would use the REST API for this. Examples are here –
https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue.
You'll either need to know the field ID (customfield_10000) or you need to to script the discovery of the field by searching the metadata – https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-discovering-meta-data-for-creating-issues.
An example of setting a custom field while creating the issue over API –
curl -D- -u fred:fred -X POST --data {"fields":{"project":{"key": "TEST"}, "summary": "Always do right. This will gratify some people and astonish the REST.", "description": "Creating an issue while setting custom field values", "issuetype":{"name": "Bug"}, "customfield_10000": [{"value": "Impediment"}]}} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
non-minified data Expand source
{
"fields": {
"project":
{
"key": "TEST"
},
"summary": "Always do right. This will gratify some people and astonish the REST.",
"description": "Creating an issue while setting custom field values",
"issuetype": {
"name": "Bug"
},
"customfield_10000": [ {"value": "Impediment" }]
}
}
As mentioned here, "Flagged" is a checkbox custom field that accepts a single value "Impediment".
You should be able to set it using the JIRA REST API just like any other custom field. Maybe the examples here will help.
You can also set custom field values using the JIRA Java API.
I'm struggling with this right now. It seems that the Flagged field is not a checkbox type field anymore, but multicheckbox. So the data format I need to send to Jira Cloud API to set the flag in my case look like this:
{update:
{customfield_10021:
[{set:
[{id:“10019”}]
}]
}
}
To remove the flag the data I sent to Jira look like this:
{update:
{customfield_10021:
[{set:
[]
}]
}
}
In the above customfield_10021 is Flagged field's key and 10019 is id that sets the flag. Both of them you need to figure out for your Jira Cloud instance for example by aquiring issue with set Flagged field and checking how it is set.
Just to make it clear, to add/remove a flag I use edit issue end point described here.
Also, to be able to add/remove flag the Flagged field has to be on the edit screen of the issue type that you want to modify and your user needs to have proper priviliges.
I have created two users, and if i create a bucket for one user and an object inside that bucket i can share it using the HTTP api at the moment.. see here
https://simperium.com/docs/reference/http/#objectshare
However, even when i sent through "write_access" = true and get a 200 as a result, it doesnt seem to let me write to it.
Its only if i enable sharing back the other way that it allows data to sync both ways, am i doing something wrong?
Has collaboration got any further yet? i can see there is a long but no docs as yet? anyone know?
After some more trial & error, I found the solution:
to edit the shared object, the target user (ie the user that the object was shared with) needs to use an objectId that is equal to: <original_user_simperiumId>/<original_objectId> to edit the object.
If you just use <original_objectId> it won't work.
So the full command for editing a shared object, using curl:
curl -H 'X-Simperium-Token: {auth_token_of_target_user}' https://api.simperium.com/1/{appID}/{entity}/i/{original_user_simperiumId>/{original_objectId} -d '{"data_key" : "new_data_value"}'
when we create projects via API the newly created project is immediately returned in both the webApp and in the API.
But a tag created using API "https://app.asana.com/api/1.0/tags" is often returned only after two or three GET requests. Also in the webApp it needs a refresh, online application sync does not update new tags like Projects.
This late returns really affects the user interaction. I follow the same workflow thats used for creating and adding project, but tags feels a bit laggy. Am I missing anything?
The answer is that tags which aren't associated with any tasks are - unfortunately - hidden in the app, and consequently also in the API. As you discovered, you can get the ID back from the POST to create and then associate it with a task from there (since there's little purpose in creating a tag if you're not associating it with something that shouldn't typically be a problem, but it is clunky). We are looking at changing our data model for tags to be a bit more intuitive in future, but that's still a ways off, so this is the reality for the foreseeable future.
the newly created tag is missed in the GET /tags API from time to time. But the http response returned after creation of the new tag by POST /tags, will contain the id, name and other properties of the newly created tag. So we can add the new tag from this response.
POST-> https://app.asana.com/api/1.0/tags \
-u "name=fluffy" \
-u "workspace=14916"
# Response
HTTP/1.1 201
{
"data": {
"id": 1771,
"name": "fluffy",
...
}
}