How Do I add a Category to a new Survey via API V3? - surveymonkey

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.

Related

Use the public GitHub API to get all merged pull requests in a JSON format

I am trying to get all the closed and merged commits on a certain repository using the github API (https://api.github.com/), and the only way I have found to do this is to check for commits that are closed (api.github.com/repos/user/repo/pulls?state=closed), then make sure the merged_at is not equal to null, but this is a slow way to do it. Is there a way to make github check if the PR is closed and has been merged at the same time directly in the url? Something like api.github.com/repos/user/repo/pulls?state=closed?is_merged=true? And return all the PRs matching the criteria?
NOTE: this has nothing to do with the /repos/user/repo/pulls/pr_id/merge, because that only tells you if a single pull request is merged, and does not search everywhere in the list of PRs.
You can use the “is:merged” operator in your search query
Check this out: https://docs.github.com/en/github/searching-for-information-on-github/searching-issues-and-pull-requests#search-based-on-the-state-of-an-issue-or-pull-request
Request template
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/search/issues\?q\=repo:{repo_owner}/{repo}+is:pr+is:merged
Explanation:
You can't get merged pull requests by std Github API /pulls route. But you can do this using Search API.
More info in docs:
Use Search API: https://docs.github.com/en/rest/search#about-the-search-api
More tricks for search issues and prs: https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests

JIRA: pair old/new IssueKey after changing project

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.

How to run report of issues in Jira added to specific sprint after specific date?

How can I run report of issues in Jira added to specific sprint after specific date ? Update date won't help as that one gets updated with lots of different actions. Any ideas?
Similarly, any way how to report on issues created in specific project / moved to specific project after specific date ?
Preferably thru Web UI, but JIRA API would be fine too.
Thanks!
So here is a little script jira-issue-search.sh:
#!/bin/bash
JIRA_USER=your_username
JIRA_PASS=your_password
JIRA_REST=http://jira.tld/rest/api/2
Q=${1?Search Query}
E=${2?Expand fields}
DATA="{\"jql\":\"${Q:q}\",\"validateQuery\":\"true\",\"startAt\":0,\"maxResults\":100,\"expand\":[\"${E:q}\"]}"
curl -s -u ${JIRA_USER}:${JIRA_PASS} -X POST -H "Accept: application/json" -H "Content-Type: application/json" --data "${DATA:q}" ${JIRA_REST}/search | json_xs -f json -t json-pretty
And you will run it as: jira-issue-search.sh 'Sprint = \"YourSprintName\"' changelog
The resulting json will have array called 'issues', which contains records with fields key and changelog/histories[]/ { items[]/field=Sprint, created > your_date }. I have a bunch of scripts to do queries in json, but you probably want to write that in whatever language you are using.
To answer the second question it depends on how you model projects. If you use jira projects, then issues cannot be moved between them so it is just creation date comparison, but if you use some custom field, you can compare on the field by searching changelog items/field = field_name and items/to = project_name and again compare created in that changelog entry to your_date.

JIRA API create issue with custom fields

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

Asana tag API query often misses newly created Tags

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",
...
}
}

Resources