Get ALL worklog from Jira REST API - rest

is there a working REST curl to get all worklog of every issue there is,
I ve tried POST /rest/api/2/worklog/list , but I dont have a list of worklog ids !!
and I don't wanna go through issues either

you can try this POST API : /rest/tempo-timesheets/4/worklogs/search which required few request body params as : {"from":"2018-11-01","to":"2018-11-30","epicKey":["epic-key1"],"projectKey":["project-key1"]}.

If you do not want to go through all the issues, you can get the worklog IDs via Get ids of worklogs modified since REST API. The response body will contain the IDs you can use for /rest/api/2/worklog/list.

You will have to go through issues. The fastest way is to execute a search with JQL query: worklogDate > 0 that will return all the issues that have any worklogs. Then you will have to ask for worklogs of each returned issue.
Both resources, search results and worklogs of issue are paginated resources so you will have to iterate to get all the worklogs of all the issues (unless you have a small instance).

IDS=$(echo {1001..2000} | tr ' ' ',') && curl \
-u username:password \
-X POST \
--data '{"ids":['$IDS']}' \
-H "Content-Type: application/json" https://jira.com/rest/api/2/worklog/list

Related

Supabase: get table count in rest mode

There is any way to get the table count in rest mode?
I'm using query params like:
https://urt.to.supabase/rest/v1/table?select=field,another_field
I was googling it out but without success.
What you need to do is to add Prefer: count=exact to the request header.
Example of this using curl would be like this:
curl "https://urt.to.supabase/rest/v1/table?select=field,another_field" -I \
-H "Prefer: count=exact"
The count value will be the number after / on the content-range header on your response. In the following example, row count is 3573458.
Content-Range: 0-24/3573458
You can read more about it on postgrest documentation here.
Note that with the Supabase.js library, you easily get the count of
const { data, error, count } = await supabase
.from('cities')
.select('name', { count: 'exact' })
You can read more about it on the official docs.

Get ads and their image in the same query

I'm using the graph API and trying to get a list of ads with their insights and post images.
I don't want to do multiple queries for this as I quickly hit the "(#17) User request limit reached" issue even when I use batch queries.
My current query looks like this:
/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative
Now in order to get the post image, I need to take the creative ID that is returned and use it in another query to pull the post like this:
/CREATIVE_ID/?fields=object_story_id
Then use the returned story id to pull the picture like:
/OBJECT_STORY_ID/?fields=picture
Is there any way I can combine these queries to do less requests?
Something like:
/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative{object_story_id{picture}}'
Any help is appreciated. Thanks.
Facebook's Batch API may work for you. It allows for multiple Graph API calls to be made from a single HTTP request and supports dependencies between those requests. Read over the documentation for details and here's a example curl call of how it might work (I've not executed this call so please review against the API documentation and test).
curl \
-F 'access_token=...' \
-F 'batch=[
{
"method":"GET",
"name":"ads",
"relative_url":"/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative",
},
{
"method":"GET",
"name":"creative",
"relative_url":"/{result=ads:$.data.*.creative}/?fields=object_story_id"
},
{
"method":"GET",
"relative_url":"/{result=creative:$.data.*.object_story_id}/?fields=picture"
}
]' \
https://graph.facebook.com

Send advanced push notification in parse.com with Rest API

Im trying to send push with two criteria in where.
I make this so:
curl -X POST
-H "X-Parse-Application-Id: myappId" \
-H "X-Parse-REST-API-Key: myRESTApiId" \
-H "Content-Type: application/json" \
-d '{
"where": {“$and”:[{“deviceType": "winphone”},{”channels":{"$all":[“string1”],"$nin":[“string2”]}}]},
"data": {"alert": “String1 is comming”}
}' \
https://api.parse.com/1/push
Something like: https://parse.com/questions/rest-api-or-constraint-on-multiple-fields-using-where, but I getting error message: error code 107 - invalid JSON Parse
How can I send push notification for given device and for given channel with condition $all and $nin.
Thanks for your help!
Hipek
This error is likely being returned because your where value does not match the REST API spec. You will also want to make sure you are consistent in your use of double quotes as these can also lead to malformed JSON errors (e.g. do not use “ and ”, use ").
After fixing that, we end up with the following, which is still not valid per the REST API Parse docs:
"where": {
"$and": [
{"deviceType": "winphone”},
{"channels": {
"$all": ["string1"],
"$nin":["string2"]}
}
]
},
There's a couple of problems with your query:
$and is not a valid Parse REST API operator, and does not appear in the REST API docs. All constraints in a where query are implicitly ANDed, so this is unnecessary, anyway.
Your $all and $nin constraints over channels conflict with each other as there cannot be more than one such query per key. You may want to instead create a unique channel for those installations that should receive messages aimed at the string1 channel but not the string2 channel.

POST multiple worklogs in one JIRA Rest request

I have the following data, hoping to insert two worklogs at once into the same issue using the rest url:
curl -u jogbra:jogbra -X POST -k --data #data_holiday.txt -H "Content-Type: application/json" https://jira.myworkplace/jira/rest/api/2/issue/4371/worklog
data_holiday.txt contains:
{
"comment": "Christmas Day",
"started": "2015-12-25T08:50:09.423+0000",
"timeSpent": "8h 0m"
},
{
"comment": "Labor Day",
"started": "2015-09-07T08:50:09.423+0000",
"timeSpent": "8h 0m"
}
It only gets the first holiday (with or without the comma).
End goal is to automate the population of holidays. I don't see a way of making more than one worklog with one request, so should I resort to using a loop to call curl? If I do that, do I need to create one data file for each holiday?
I see from this post that google has solved this batch request issue with a "batch" endpoint. How would I accomplish this in jira?
Sorry, but in JIRA only one worklog per on request: https://docs.atlassian.com/jira/REST/latest/#d2e795

Getting users information from moodle

How to get the section's user information (like name, password)? Is there any method that returns it?
I'm trying the function "core_user_get_users_by_field", but it isn't works. That's I've done:
String serverurl = url + "/webservice/rest/server.php" + "?wstoken=" + token + "&wsfunction=" + functionName;
obs: The server was constructed using REST.
This works for me
/webservice/rest/server.php?wstoken=xxx&wsfunction=core_user_get_users_by_field&field=id&values[0]=2
2 is the user id.
You can use any field that uniquely identifies the user. eg: field=username
You can also retrieve more than one user at a time eg: values[0]=2&values[1]=3
This is assuming the function was added as a web service following these instructions
http://docs.moodle.org/25/en/Using_web_services
There is global object called $USER in moodle, this object contains all information about user, So where you want these information just access like,
global $USER; // <= don't forget to write this before to access
$USER->username;
$USER->firstname;
$USER->lastname;
$USER->password;
Its works with:
https://url.moodle.xyz/webservice/rest/server.php?wstoken=XXXXXXX&wsfunction=core_user_get_users_by_field&field=id&values%5B0%5D=1306
The query parameters:
wsfunction=core_user_get_users_by_field
field=id
values[0]=1234
values[0] is user id.
To get moodle userdetails based on user name you can use like this :
/webservice/rest/server.php?wstoken=8888&wsfunction=core_user_get_users_by_field&field=username&values[0]=mark
To get JSON data Use :
/webservice/rest/server.php?wstoken=8888&wsfunction=core_user_get_users_by_field&field=username&values[0]=mark&moodlewsrestformat=json
Via curl POST request:
curl \
-X POST \
--data-urlencode "wstoken=123456789..." \
--data-urlencode "wsfunction=core_user_get_users_by_field" \
--data-urlencode "field=id" \
--data-urlencode "values[0]=123456" \
https://moodle.domain.tld/webservice/rest/server.php
As Russell England said:
[...] use any field that uniquely identifies the user. eg: field=username