Change status of issue in Jira using Rest call from Python - python

I am trying to update the status of issue from 'Request Info' state to 'Submitted' via rest API in python.
after digging a lot in the documentation , I ran a Rest call to get the allowed status for the issue ID and i can see that the status 'Submitted' is allows:
"expand": "transitions",
"transitions": [{
"id": "381",
"name": "Resubmit",
"to": {
"self": "https://ies-valor-jira.ies.mentorg.com/rest/api/2/status/10000",
"description": "",
"iconUrl": "https://ies-valor-jira.ies.mentorg.com/",
"name": "Submitted",
"id": "10000",
"statusCategory": {
"self": "https://ies-valor-jira.ies.mentorg.com/rest/api/2/statuscategory/2",
"id": 2,
"key": "new",
"colorName": "blue-gray",
"name": "To Do"
So now i would like to change the status with the following code:
from jira import JIRA
JIRA_SERVER = "https://ies-valor-jira.ies.mentorg.com/"
jira_user_name = "myuser"
jira_password = "mypassword!"
jira_connection = JIRA(basic_auth=(jira_user_name, jira_password),
server=JIRA_SERVER)
jira.Issue='SF-6831'
jira_connection.add_comment(jira.Issue, body="Resubmit issues")
jira_connection.transition_issue("SF-6831", "Resubmit")
But i get an error message that indicate :customfield_10509":"You must define "Resubmit Note: before you moving to "CCB Review" state"}
this error is expected because this field is mandatory and it must be filled with a reason for the status change so i need to know how to update this custom field in the Rest call to allow the issue to change status.
I tried to use add.command function but i don't know where i should specify the field name.
or is there a different way to do it.
Thanks.

I do most of this work in straight Python using the API, I have a lot of what you need in this repo - https://github.com/dren79/JiraScripting_public
I'll add a transition function in the helpers file now.
Let me know if it helps!

Related

Why does executing a webhook via the discord API return a 404 error?

Whilst trying to execute a webhook, I've been getting 404 errors. The url I'm using is exactly what the Discord docs tell me to use: https://discord.com/api/v10/webhooks/{webhook.id}/{webhook.token}. However, I've been able to successfully create and delete webhooks. Finally, to test this error, I waited about a day after creation to see if it took some time for the url to work, but this also turned up a 404 error.
When creating a webhook, I use this method. Upon doing so, it returns json containing something like this:
{
"name": "test webhook",
"type": 1,
"channel_id": "199737254929760256",
"token": "3d89bb7572e0fb30d8128367b3b1b44fecd1726de135cbe28a41f8b2f777c372ba2939e72279b94526ff5d1bd4358d65cf11",
"avatar": null,
"guild_id": "199737254929760256",
"id": "223704706495545344",
"application_id": null,
"user": {
"username": "test",
"discriminator": "7479",
"id": "190320984123768832",
"avatar": "b004ec1740a63ca06ae2e14c5cee11f3",
"public_flags": 131328
}
}
I used this bit of documentation to attempt to execute the webhook to send a message but to no avail. I use a url that uses the id and token in the json of the webhook, so with the JSON above, the url would look like this: https://discord.com/api/v10/webhooks/223704706495545344/3d89bb7572e0fb30d8128367b3b1b44fecd1726de135cbe28a41f8b2f777c372ba2939e72279b94526ff5d1bd4358d65cf11. I have checked to make sure that the program is using the right URL, and it is. What am I doing wrong to get the 404 error?
Thanks in advance.
You are using the API correctly from what I can tell, it's likely something that goes wrong when executing the webhook.
You can verify this by sending a get GET request to your webhook URL (for example by opening it in your browser), and see what response you get.
For example, a successful call for this URL would look like this:
https://discord.com/api/v10/webhooks/730533481892106727/aPKOoEoamLq9pVnKHT3gF-whSrtrsnkWlOA3xPQPMNBsK5vhe9PC82-e7bu3BEFESQfaw
{
"type": 1,
"id": "730533481892106727",
"name": "Spidey Bot",
"avatar": null,
"channel_id": "501452852364050123",
"guild_id": "413797995205889283",
"application_id": null,
"token": "aPKOoEoamLq9pVnKHT3gF-whSrtrsnkWlOA3xPQPMNBsK5vhe9PC82-e7bu3BEFESQfaw"
}
It seems like missing a forward-slash / will result in a 404, so that might be your issue.

How to resolve the error: "columns[11]: custom variable cannot be found" when running an SA360 API call?

Heyy!!
Hope everyone is doing well,
I'm pulling data from SA360 (or DS3, Doubleclick Search), although I receive this error when I try to download the report:
"columns[11]: A custom variable named 'DDA Product Sign Ups' with
platform source 'FLOODLIGHT' cannot be found.">
I know:
That conversion exists on the platform UI (second result)
That my script works because when I take off the conversion field I can deploy my function with no prob.
My Script (more or less):
conversion_name = "DDA Product Sign Ups"
request = ds3_manager.reports().request(body =
{
"reportScope": {
"agencyId": agency_id,
"advertiserId" : advertiser_id },
"reportType": "adGroup",
"columns": [
{ "columnName": "date"},
{ "columnName": "accountType"},
{ "columnName": "account" },
{ "columnName": "cost" },
{ "columnName": "impr" },
{ "columnName": "clicks" },
{
"customMetricName" : conversion_name,
"platformSource": "floodlight"
}
],
"timeRange": {
"startDate": start_date,
"endDate": end_date
},
"downloadFormat": "csv",
"maxRowsPerFile": 6000000,
"statisticsCurrency": "agency"
}
)
When I google the issue I land on this web result: Set up custom Floodlight metrics and dimensions but I don't understand, to me, it is already set up, as I can add to it to my reports on the UI or on my webqueries already... So I'm not why it is not picked up by the script..
If anyone has an idea that would be greatly appreciated :D.
Best,
Alex
In order to include custom columns in a report request, you first need to find out how that custom column is defined (check this link). You can then include the custom column in the request (check this link).
You will find useful information on this topic in the "Optional: Request for Specific User-defined Column" section of this article.

Is there a way to obtain Facebook Insights for specific posts trough the Graph API?

Sorry to bother with maybe a stupid question, but I'm still a beginner with the Graph API. A little background to better understand my question: I need to run an analysis on a Facebook page (of which I'm not the owner but administrator, small size, ~4000 likes and ~150 posts, more or less one per day). What I intended to do was the following:
Obtain the data trough Graph API. Namely, I was most interested in retrieving the messages, number of likes and reach of every post
Import the data in R and identify the outliers (I mean, the posts whose likes and reach are not in line with the mean)
Look for correlations between those messages (since the page, for its nature, needs to talk about a wide range of topics, I want to understand which of them generate the most reactions and plan accordingly)
I've already done an analysis "by hand", but I want to test if it is possible to make the same conclusions without involving a human operator.
I've looked on the web for tutorials on how to use the graph API in python, but I've not been able to find something comprehensive. I've set up my API and obtained the permanent page token with manage_pages and read_insights permissions.
Here an idea of what I'm doing:`
def get_facebook_page_data(page_id, access_token):
website = "https://graph.facebook.com/v3.1/"
location = "%s/posts/" % page_id
fields = "?fields=message,id" + \
"reactions.type(LIKE).limit(0).summary(total_count).as(reactions_like)"
authentication = "&limit=100&access_token=%s" % (access_token)
request_url = website + location + fields + authentication
data = json.loads(request_data_from_url(request_url))
return data`
So, with this function I'm able to obtain the id, message and number of likes of all the posts stored inside data, and with another function I write everything on a csv file.
First question: am I doing something wrong?
Second question: I cannot retrieve a lot of information. For example, when adding type to the fields, it says that this is deprecated (I'm running python 3.7.3)
Third questions: how do I retrieve the reach for every post? I'm assuming this is obtained by scraping the insights, by I don't seem to get it right... How do I query the Graph API for those data?
In general, I'm finding a lot of trouble in just getting the right keywords while building the links. I've installed facebook-sdk but I don't know how to use it (as I said, I'm a beginner). Do you have suggestions on this?
Thanks very much to everyone answering, and greetigs from Italy!
First of all I suggest to use the latest version of the API available, currently the 5.0, regarding your question:
Second question: I cannot retrieve a lot of information. For example,
when adding type to the fields, it says that this is deprecated (I'm
running python 3.7.3)
Regarding to the doc of the Page Feed see the attachments field, as example, adding this to the request:
attachments.fields(media_type)
Third questions: how do I retrieve the reach for every post? I'm
assuming this is obtained by scraping the insights, by I don't seem to
get it right... How do I query the Graph API for those data?
Regarding to the doc of the Page Insights see the page_impressions field, as example in order to return the page_impressions field for a lifetime period:
insights.period(lifetime).metric(post_impressions_unique)
A complete example:
https://graph.facebook.com/v3.1/<PAGE-ID>/posts?fields=message,id,reactions.type(LIKE).limit(0).summary(total_count).as(reactions_like),insights.period(lifetime).metric(post_impressions_unique),attachments.fields(media_type)
Will return:
{
"data": [{
"message": "Hello",
"id": "269816000129666_780829305694997",
"reactions_like": {
"data": [],
"summary": {
"total_count": 0
}
},
"insights": {
"data": [{
"name": "post_impressions_unique",
"period": "lifetime",
"values": [{
"value": 15
}],
"title": "Lifetime Post Total Reach",
"description": "Lifetime: The number of people who had your Page's post enter their screen. Posts include statuses, photos, links, videos and more. (Unique Users)",
"id": "269816000129666_780829305694997/insights/post_impressions_unique/lifetime"
}],
"paging": {
"previous": "https://graph.facebook.com/v3.1/269816000129666_780829305694997/insights?access_token=EAAAAKq6xRNcBAOMKY3StjWXPgL1REATIfPFsyZCY21KDAnZAZB7MpKgNGCHRlKVt9bZBoVZAHpV0jqxZAAVZCOKDIh96YxvpxPaavR1AYK5EQCEEOSMKqz4ZAItcX9WvVfEEN5FzqgyoQWi8oKZBQmQB4Nf80SgicaesluNbI0hDMw2QAxfV9rAFpRc10Pop1d1vtVeziPEjEKwZDZD&metric=post_impressions_unique&period=lifetime&since=1573891200&until=1574064000",
"next": "https://graph.facebook.com/v3.1/269816000129666_780829305694997/insights?access_token=EAAAAKq6xRNcBAOMKY3StjWXPgL1REATIfPFsyZCY21KDAnZAZB7MpKgNGCHRlKVt9bZBoVZAHpV0jqxZAAVZCOKDIh96YxvpxPaavR1AYK5EQCEEOSMKqz4ZAItcX9WvVfEEN5FzqgyoQWi8oKZBQmQB4Nf80SgicaesluNbI0hDMw2QAxfV9rAFpRc10Pop1d1vtVeziPEjEKwZDZD&metric=post_impressions_unique&period=lifetime&since=1574236800&until=1574409600"
}
},
"attachments": {
"data": [{
"media_type": "photo"
}]
}
},
{
"message": "Say hello!",
"id": "269816000129666_780826782361916",
"reactions_like": {
"data": [],
"summary": {
"total_count": 0
}
},
"insights": {
"data": [{
"name": "post_impressions_unique",
"period": "lifetime",
"values": [{
"value": 14
}],
"title": "Lifetime Post Total Reach",
"description": "Lifetime: The number of people who had your Page's post enter their screen. Posts include statuses, photos, links, videos and more. (Unique Users)",
"id": "269816000129666_780826782361916/insights/post_impressions_unique/lifetime"
}],
"paging": {
"previous": "https://graph.facebook.com/v3.1/269816000129666_780826782361916/insights?access_token=EAAAAKq6xRNcBAOMKY3StjWXPgL1REATIfPFsyZCY21KDAnZAZB7MpKgNGCHRlKVt9bZBoVZAHpV0jqxZAAVZCOKDIh96YxvpxPaavR1AYK5EQCEEOSMKqz4ZAItcX9WvVfEEN5FzqgyoQWi8oKZBQmQB4Nf80SgicaesluNbI0hDMw2QAxfV9rAFpRc10Pop1d1vtVeziPEjEKwZDZD&metric=post_impressions_unique&period=lifetime&since=1573891200&until=1574064000",
"next": "https://graph.facebook.com/v3.1/269816000129666_780826782361916/insights?access_token=EAAAAKq6xRNcBAOMKY3StjWXPgL1REATIfPFsyZCY21KDAnZAZB7MpKgNGCHRlKVt9bZBoVZAHpV0jqxZAAVZCOKDIh96YxvpxPaavR1AYK5EQCEEOSMKqz4ZAItcX9WvVfEEN5FzqgyoQWi8oKZBQmQB4Nf80SgicaesluNbI0hDMw2QAxfV9rAFpRc10Pop1d1vtVeziPEjEKwZDZD&metric=post_impressions_unique&period=lifetime&since=1574236800&until=1574409600"
}
},
"attachments": {
"data": [{
"media_type": "photo"
}]
}
},

How do I pull new employee information from DocuSign through API?

Is it possible to pull the new employee’s personal information who gets hired every day from DocuSign through API? I'm trying to find a way to automate the process of user account creation process from DocuSign to Active Directory by avoiding CSV file. New to this, any input might be useful?
There are two parts to this endeavor.
The first, is not related to DocuSign. You need to get an event fired everytime a new contact is added to AD and be able to process this request. I assume you have a way to do that.
Then, the second part is using our REST API to add a new user.
Make a POST request to:
POST /v2.1/accounts/{accountId}/users
You pass this information in the request body:
{
"newUsers": [
{
"userName": "Claire Horace",
"email": "claire#example.com.com"
},
{
"userName": "Tal Mason",
"email": "tal#example.com.com",
"userSettings": [
{
"name": "canSendEnvelope",
"value": "true"
},
{
"name": "locale",
"value": "fr"
}
]
}
]
}

Python facebook-sdk: retrieving names of users who posted a message on a page

I want to use the Python facebook-sdk library to retrieve the names of the persons who posted a message on a Facebook page I created.
This is an example, returned by the Graph API explorer:
{
"feed": {
"data": [
{
"from": {
"name": "Ralph Crützen",
"id": "440590514975673"
},
"message": "Nog een test.",
"created_time": "2015-10-17T19:33:30+0000",
"id": "649463214822976_649745285127205"
},
{
"from": {
"name": "Ralph Crützen",
"id": "440590514975673"
},
"message": "Testing!",
"created_time": "2015-10-16T20:44:17+0000",
"id": "649463214822976_649492455153388"
},
... etc ...
But when I use the following Python code...
graph = facebook.GraphAPI(page_access_token)
profile = graph.get_object('tinkerlicht')
posts = graph.get_connections(profile['id'], 'feed')
print(posts['data'][0]['message'])
print(posts['data'][0]['from']['name'])
...only the message value is printed. Printing the name of the person who posted the message gives the error:
print(posts['data'][0]['from']['name'])
KeyError: 'from'
At first, I thought that I needed the read_page_mailboxes permission. To use this permission, it has to be approved by Facebook, so I submitted a request. But Facebook replied:
"You don't need any additional permissions to post to Pages or blogs that you administer. You only need to submit your app for review if your app will use a public-facing login."
So what exactly is the reason I can't retrieve the from data from the messages feed? (While reading it from the Graph API explorer works fine...)
Btw, I'm using a page access token which never expires. I generated this token the way it's described here.

Categories