get multiple user data in a single query - asana

I did the following.
curl -u $API_KEY https://app.asana.com/api/1.0/users
then I collect the IDs of all users.
Is there a way to get all users info in a single query. I want some think like
curl -u $API_KEY https://app.asana.com/api/1.0/users/2423237500000 & 7124173919380
instead of two separate query
curl -u $API_KEY https://app.asana.com/api/1.0/users/2423237500000
curl -u $API_KEY https://app.asana.com/api/1.0/users/7124173919380

(I work at Asana.)
When you retrieve the list of users you can fetch more than just their ID and name. Use the opt_fields parameter for specific individual fields, or if you really need the whole record than use opt_expand, as described in the docs here:
https://asana.com/developers/documentation/getting-started/input-output-options

Related

How do I get the conversation SID using data from Messaging Monitor screen?

I have an old Conversation's Channel ACTIVE with my phone number, so the incoming messages are not entering the Studio's flow. I need the Conversation's Channel SID so I can close that channel using the API Explorer.
The only data I have is that the message was received using the Monitor>Messaging screen in Twilio Console.
Monitor Image description
But I don't find an API that I can use to get the SID I need with the data I have
Right now, I built a bash script to fetch all conversations and (when the script finishes) I will grep the whatsapp number to find the conversation SID.
#!/bin/bash
ACCOUNT_SID=ACXXXXXXXXXXXXXXXXX
AUTH_TOKEN=XXXXXXXXXXXXX
PAGE_SIZE=100
DOWNLOAD_PAGES=1000
CURRENT_PAGE=${DOWNLOAD_PAGES}
DOWNLOAD_DIR=downloaded_channels
rm -rf ${DOWNLOAD_DIR}
mkdir -p ${DOWNLOAD_DIR}
while (( ${CURRENT_PAGE} >= 0 )); do
echo "downloading Page ${CURRENT_PAGE}"
curl 'https://conversations.twilio.com/v1/Conversations' -u ${ACCOUNT_SID}:${AUTH_TOKEN} > ${DOWNLOAD_DIR}/page_${CURRENT_PAGE}.json
sleep 0.1
(( CURRENT_PAGE=$CURRENT_PAGE-1 ))
done
The problem with this approach is that I have thousands (if not millons) of conversations and Twilio's API allow result pages of 100 elements max. So if I'm not lucky to find my conversation in the first downloaded pages, I will be here forever.
Does anyone know a better approach for this?
If you're using the Conversations API, you can use the Participants Conversations API to search by your address on Twilio and get all conversation assigned to your number.
Follow the documentation of API: https://www.twilio.com/docs/conversations/api/participant-conversation-resource
Follow an example using the Twilio CLI:
twilio api:conversations:v1:participant-conversations:list --address "whatsapp:+myNumber" --properties conversationSid,conversationState --no-limit
If you're using the Programmable Chat, doesn't have an API to search by your phone, but you can search all and use a filter to get just the Channels with your number on attributes (The process can during a long time depending of the quantity of conversations in your account).
Follow an example using the Twilio CLI:
twilio api:chat:v2:services:channels:list --service-sid <service_sid> --properties sid,attributes --no-limit | grep myNumber
I hope that it can help you! :D
Twilio fanatic here.
According to the Conversation resource page, as you are using CURL you can specify the request parameters in the request URL, similar to how you would using Twilio's native API functions (read()).
From the Conversation Resource documentation (modified to include State and DateCreated parameters):
curl -X POST "https://conversations.twilio.com/v1/Conversations" \
--data-urlencode "State=active" \
--data-urlencode "DateCreated=>=YYYY-MM-DD" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
Please be sure to urlencode the DateCreated parameter as it includes non-URL friendly symbols (>= to reference on or after- I am not sure if the written format is suitable for bash as-is).
You may use any of the 10 available Conversation parameters to specify which Conversations are returned. As stated, one or more lines or variable names may not be suited for your application as-is, but with a bit of finagling should produce the result you're looking for. For example, DateModified or looking for a custom value placed under attributes might suit your case better.
If this helps, please upvote. I am trying to get noticed by Twilio and get hired to fulfill my dream of working while RVing fulltime.

gerrit - query command with multiple numbers

How to query gerrit with multiple gerrit numbers? for example, I have two gerrit with number 1234 and 5678, I wish use one query url to list all gerrits!
Maybe something like below:
http://codereview.com/a/q={1234,5678}
This is helpful, I can share one link to others for multiple gerrits review!
Use the following URL in your browser:
http://codereview.com/q/1234+OR+5678
The following command gets the information you want using the REST API:
curl --user USER:PASS --request GET "http://codereview.com/a/changes/?q=1234+OR+5678"

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 Do I add a Category to a new Survey via API V3?

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.

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.

Resources