Is it possible to create a MULTI_PICKLIST with Smartsheet Python SDK? - smartsheet-api

I am trying to create a MULTI_PICKLIST column using Smartsheet's Python SDK, but receive an error saying
"errorCode": 1012,
"message": "Required object attribute(s) are missing from your request: column.type.",
I'm using the following to try and add the column:
column = smartsheet.models.Column({
'title': 'TEST COLUMN',
'type': 'MULTI_PICKLIST',
'index': 0,
'options': ['One', 'Two']
})
response = smart.Sheets.add_columns(sheetid, column)
Is it currently possible to create a MULTI_PICKLIST Column with Python or has the SDK not been updated to support this? I also tried creating a regular PICKLIST then using update_column to update its type, but I similarly receive an error.

The Python SDK has not been updated to support MULTI_PICKLIST. In the meantime you could conceivably use the passthrough option to support creating a MULTI_PICKLIST column. There is more detail in the Python SDK documentation here: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/ADVANCED.md#passthrough-option

The Python API docs were updated on 2019-11-08 for MULTI_PICKLIST. There may be functionality there you are looking for.

Related

Create issue via python rest api jira

So, I have written python code which interact with Jira api via python library atlassian_python_api
from atlassian import Jira
jira = Jira(
url="https://jira.example.com/",
username='gonchik.tsymzhitov',
password='admin')
jira.issue_create(fields={
'project': {'key': 'TEST'},
'issuetype': {
"name": "Task"
},
'summary': 'test rest',
'description': 'rest rest',
})
After the issue has been created with key TEST-2045 (the number 2045 was generated automaticly).
The question is: How can I insert my own issue number? For example, TEST-15 ?
that's the 'key' field.
and you can't provide it while creating jira issue, it's predefined behavior
see the topic at atlassian forum: https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-specify-key-when-creating-issue-via-API/qaq-p/574472
For those of you who might run into the error JIRA' object has no attribute 'issue_create':
it should be "jira.create_issue".

How to send a list as parameter in databricks notebook task?

I am using Databricks Resi API to create a job with notebook_task in an existing cluster and getting the job_id in return.
Then I am calling the run-now api to trigger the job.
In this step, I want to send a list as argument via the notebook_params, which throws an error saying "Expected non-array for field value".
Is there any way I can send a list as an argument to the job?
I have tried sending the list argument in base_params as well with same error.
user_json={
"name": job_name,
"existing_cluster_id": cluster_id,
"notebook_task": {
"notebook_path": notebook_path
},
"email_notifications":{
"on_failure":[email_id]
},
"max_retries": 0,
"timeout_seconds": 3600
}
response=requests.post('https://<databricks_uri>/2.0/jobs/create',headers=head,json=user_json,timeout=5, verify=False)
job_id=response.json()['job_id']
json_job={"job_id":job_id,"notebook_params":{"name":"john doe","my_list":my_list}}
response = requests.post('https://<databricks_uri>/2.0/jobs/run-now', headers=head, json=json_job, timeout=200, verify=False)
Not found any native solution yet, but my solution was to pass the list as a string and parse it back out on the other side:
json_job={"job_id":job_id,
"notebook_params":{
"name":"john doe",
"my_list":"spam,eggs"
}
}
Then in databricks:
my_list=dbutils.widgets.get("my_list")
my_list=my_list.split(",")
With appropriate care around special characters or e.g. conversion to numeric types.
If the objects in the list are more substantial, then sending them as a file to dbfs using the CLI or API before running the job may be another option to explore.
Hi may be I'm bit late but found a better solution.
Step 1:
Use JSON.stringyfy() in the console of any browser to convert your value(object, array, JSON etc) into string
Ex:
Now use this value in the body of URL
In Databricks notebook convert string to JSON using python json module.
Hope this helps

Custom Dimensions Not Reporting Through to Google Analytics API V4

I am attempting to pass information collected as, "custom dimensions," from Google Tag Manager through Google Analytics and then extract them out via the Google Analytics V4 API.
I have set up four of the fundamental custom dimensions suggested by Simo Ahava in this article.
My variable setup looks like the following:
variable setup
Essentially, I have been able to successfully pass through userID_dimension, hittimestamp_dimension, clientid_dimension and sessionid_dimension to the Google Analytics dashboard, but for some reason I am not able to extract out the hittimestamp_dimension through the API.
Here's what I am able to see on the dashboard:
Google Analytics Dashboard
As far as the API itself, I am using the HelloAnalytics.py python version supplied by Google, and I am able to extract out all of the above information, minus the timestamps dimensions on the right hand side of each.
I'm storing the timestamp information in dimension2, but upon making the below call (again, using API V4) I get blank...nothing.
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}]
}]
}
).execute()
Upon making this call, one would expect that the above would report out dimensions similar to what the Google Analytics dashboard would show. E.g. one would think that the dashboard itself is using the API. However what prints out is blank. All other custom dimensions print out as expected.
If I try to call the above function on just dimension2 itself with no other dimension, it is also blank.
Is there something special one has to do in order to extract hit-scoped variables within the API? Or does the API just not allow hit-scoped variables to pass through?
thanks,
You forgot to add a 'metrics' field to your request, it is required as per documentation
Source: Reporting API v4 - Method: reports.batchGet
The metrics requested. Requests must specify at least one metric. Requests can have a total of 10 metrics.
The below modified request should work:
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}],
'metrics': [{'expression': 'ga:sessions'}]
}]
}
).execute()

Invoking JIRA Rest API to create an issue containing a locked custom fields like Epic Name

I'm trying to create an Epic Issue in JIRA using the REST API.
There is a field called "Epic Name", which is required and locked.
When I submit the following JSON
URL: https://jira:443/jira/rest/api/latest/issue
{"fields":{"project":{"key":"TEST"},"issuetype":{"name":"Epic"},"summary":"TestSummary","Epic Name":"TestName"}}
The Response is:
Http Error : 400{"errorMessages":[],"errors":{"Epic Name":"Field 'Epic Name' cannot be set. It is not on the appropriate screen, or unknown."}}
What is wrong, since in the screen Epic Name is there and required (obviously, since it is a required attribute). What could be the problem?
Thanks
The problem is not that the field is not on the screen but that for JIRA API, the field name Epic Name is invalid/unknown. The actual ID of that field is customfield_10016 which you have to put in the query. The value should be the Issue Key for that specific Epic instead of just a name.
{
"fields": {
//other data
"customfield_10016": "PROJECTKEY-69"
}
}
I tried with customfield_10016 but it didn't work for me.
I have researched more about the same and got to know the custom field may differ for JIRA instance.
We can get custom field for our JIRA insatnce and project using below API and use it - http://<JIRA_URL>/rest/api/2/issue/createmeta?projectKeys=<ProjectKey>&issuetypeNames=<IssueType>&expand=projects.issuetypes.fields

Update Marketo lead's membership->progressionStatus using REST API

I'm trying to adapt https://github.com/Marketo/REST-Sample-Code/blob/master/php/LeadDatabase/Leads/SyncLeads.php for my own needs. I want to be able to update a lead's status from "Registered" to "Attended" using the REST API. (The Marketo Events app does this when someone is checked into an event.)
However, when I try sending something like:
{"input":[{"email":"asdfasdf#qwerqwer.org",
"membership":{"progressionStatus":"Attended"}}]}
I get back:
{"requestId":"168be#15868ee5bff",
"result":[{"status":"skipped","reasons":[
{"code":"1006","message":"Field 'membership' not found"}]}],
"success":true}
I understand the message just fine -- 'membership' isn't a field, therefore it can't be updated this way. But is there another way to update the progressionStatus using the API?
You need to be looking at that lead's membership of the program - see this method for more information: http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Leads/changeLeadProgramStatusUsingPOST
Try to use this format:
{
'status': 'Member',
'input': [
{'id': 23},
{'id': 445}
]
}
You have to use the Marketo Lead ID (not email) and you can only specify 1 status value per API call. Max batch size is 300 Lead IDs.