JIRA: /rest/api/2/issue/{issueIdOrKey}/notify - How to specify recipients - jira-rest-api

Been stuck with this. Does anyone know how to specify the recipients? I assumed the "to" specifies recipients but I still get an error that no recipients were specified.

from https://docs.atlassian.com/jira/REST/latest/#d2e3102
You can nest an array of users under to, like this:
"to": {
"users": [
{
"name": "username_1"
},
{
"name": "username_2"
}
]
},

Related

Facebook ads custom audience Data is missing or does not match schema error

i was building a integration with the facebook ads audience API, and according the documentation the request must be created like this:
POST - https://graph.facebook.com/v15.0/<MY_CUSTOM_AUDIENCE_ID>/users?access_token=<MY_ACCESS_TOKEN>
{
"session":{
"session_id":1,
"batch_seq":1,
"last_batch_flag":true,
"estimated_num_total":1
},
"payload":{
"schema":[
"FN"
],
"data":
[
"8b1ebea129cee0d2ca86be6706cd2dfcf79aaaea259fd0c311bdbf2a192be148"
]
}
}
Using the previus example a received a error 400:
{
"error": {
"message": "(#100) Data is missing or does not match schema",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "AqrLd9uIw0D4BBFtHF33bdU"
}
}
For do this i used this documentation https://developers.facebook.com/docs/marketing-api/audiences/guides/custom-audiences#hash
Anyone has use this before?
Your schema field type is array but array use form multi-key qualification.
Change it to string: schema: 'FN'
In docs you can see all formats.
This payload with multi keys work for me:
{
"session": {
"session_id": 123,
"batch_seq": 1,
"last_batch_flag": true
},
"payload": {
"schema": [
"EMAIL",
"PHONE",
"FN"
],
"data": [
["EMAIL_HASH", "PHONE_HASH", "FN_HASH"]
]
}
}

How to update the status on a Jira issue vis Jira Rest Api

I want to change the status of the project issue on Jira. The status is Open and I want to make it Fixed. My url is PUT https://jiradbg-sandbox.deutsche-boerse.de/rest/api/latest/issue/PID-XX
{
"update": {
"fields":{
"status": [
{
"set": "Fixed"
}
]
}
}
}
and the response is:
{
"errorMessages": ["Can not deserialize instance of java.util.ArrayList out of START_OBJECT token\n at [Source: org.apache.catalina.connector.CoyoteInputStream#5de98556; line: 3, column: 9]
(through reference chain: com.atlassian.jira.rest.v2.issue.IssueUpdateBean[\"update\"])"]
}
There are two problems that you are encountering here.
The first problem is update or fields should be provided separately to Jira's edit issue API, not one inside of the other. They have equivalent functionality so normally only one is used. For example to update the summary field provide either update:
{
"update": {
"summary": [
{
"set": "Updated by update"
}
]
}
}
or fields:
{
"fields": {
"summary": "Summary set by fields"
}
}
However the status field is a special case and can't be updated directly, which is the second problem here. Changing a status in Jira is called a transition. You need to trigger the transition to move the issue into the status you want.
Start by identifying the available transitions by calling the get transitions API:
GET https://example.net/rest/api/latest/issue/PID-XX/transitions
This tells you which transitions are currently available, something like this:
{
"expand": "transitions",
"transitions": [
{
"id": "21",
"name": "Fixed",
"to": {
"self": "https://example.net/rest/api/2/status/10001",
"description": "",
"iconUrl": "https://example.net/images/icons/status_generic.gif",
"name": "Fixed",
"id": "10001",
"statusCategory": {
"self": "https://example.net/rest/api/2/statuscategory/3",
"id": 3,
"key": "done",
"colorName": "green",
"name": "Done"
}
}
}
]
}
Take the id of the transition you want, in this case 21, then post it to the issue transition API:
POST https://example.net/rest/api/latest/issue/PID-XX/transitions
Use a request body like this:
{
"transition": {
"id": 21
}
}
You should get a 204 HTTP response from Jira which indicates the transition was successful.

Google sheets APIv4: Getting notes from cell

I can't find a way to retrieve notes from a cell. I looked here:https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get
I can update the note by using the code here: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells
... but I can't find a way to retrieve the note in the first place.
This the result of a values.get call on a cell that has a note...
{u'range': u'Sheet1!D5', u'values': [[u'update CD data']], u'majorDimension': u'ROWS'}
as you can see, the notes to the cell are not there.
How about using sheets/data/rowData/values/note to the fields?
The endpoint is as follows.
GET https://sheets.googleapis.com/v4/spreadsheets/### Spreadsheet ID ###?fields=sheets%2Fdata%2FrowData%2Fvalues%2Fnote
From your profile, if you use Python, how about this?
response = service.spreadsheets().get(spreadsheetId=id, fields="sheets/data/rowData/values/note").execute()
Result:
When there are notes at "A1:B2", the result is as follows.
{
"sheets": [
{
"data": [
{
"rowData": [
{
"values": [
{
"note": "sample note A1"
},
{
"note": "sample note B1"
}
]
},
{
"values": [
{
"note": "sample note A2"
},
{
"note": "sample note B2"
}
]
}
]
}
]
}
]
}
Reference:
CellData
If I misunderstand your question, please tell me. I would like to modify it.

PUT inventory custom fragment

This is my device inventory with the custom tasks array:
{
...
"c8y_IsDevice": {},
"tasks": [
{
"task_status" : "NEW",
"task_id" : "1",
"task_data" : {
...
}
},
{
"task_status" : "DONE",
"task_id" : "2",
"task_data" : {
...
}
},
...
]
...
}
I want to create a MQTT/SMARTREST PUT template to update a task by id and status.
For example: 800,[task_id],[task_status]
I am not able to find a way for this, especially it's an json array and all my attempts end up in overwriting the complete json array.
Maybe there's sth. like a condition, if task_id = x -> set task_status = y
Thank you.
You can only replace the whole fragment. There is no way to partially modify fragments.
one way to do it is get the whole array, using it for create a new one locally with the changes to want to do and finally put it again into the database. It is not a kind of solution but have been working for me.
Thanks for the info, but I still got a question about updating an array.
Concerning your answers I want to update the whole fragment.
This is my inventory:
"tasks": [
{
"address": {
"street": "Street",
"street_number": "1"
},
"description": "Test Description",
"id": "1",
"status": "NEW"
},
{
"address": {
"street": "Street2",
"street_number": "2"
},
"description": "Test Description 2",
"id": "2",
"status": "DONE"
}
]
My template:
801,<$.tasks.status>,<$.tasks.description>,<$.tasks.address.street>,<$.tasks.address.street_number>
Template screenshot
Now I publish:
//801,SERIAL,status,description,street_name,street_nr
801,SERIAL,NEW,1,2,3,4
Of course, this will overwrite the array and just set a json object tasks.
"tasks": {
"address": {
"street": "2",
"street_number": "3"
},
"description": "1",
"status": "NEW"
}
So I tried tasks[*]/tasks[] in my template (like in response templates), but this won't work too. I don't get it, maybe you can give me a small solution about putting a complete fragment with an array inside.

Dredd (gavel) : Begin a Json Schema with an array (bug ?)

I am using Markdown for Generate documentation (aglio), generate mocks (api-mock) and check the integrity constraints (dredd).
With Dredd, no problem for check an object, no problem for PUT or POST, but I have a problem with lists.
My lists are arrays, but when I write this schema :
{
"title": "Videos List",
"type": "array",
"items": {
"type":"object",
"required":false,
"properties": {
"id": {
"type": "string",
"required": true
}
},
"required": true
}
}
I get same error all the time: body: JSON schema is not valid! invalid type: object (expected [object Object]/array) at path "/items"
I've tried, again and again, 3 hours, but I failed.
Please help!
PS : sorry for my English, I'm french.
Yes, your data is correct again that schema.
It might be a specific problem of the validator your are using (you did not mention which). You can try to enclose your data with {}. I guess it is expecting allways a JSON like this:
{
[
{
"id": "ninon-retrouve-rudy",
"title": "Ninon retrouve Rudy edited"
},
{
"id": "ninon-retrouve-rudy-1",
"title": "Ninon retrouve Rudy"
}
]
}
Be aware also that your are using Draft03 of Json-schema. I suggest you to use Draft04 (your validator might be obsolete).