Jira REST API: create issue linked to another one - api

I'd like to link an issue to an existing one at creation using the REST API. The idea is not to CREATE then UPDATE, but just CREATE.
Here is my JSON:
{
"issueUpdates": [
{
"fields": {
"project": {
"key": "CMDB"
},
"issuetype": {
"id": "10500"
},
"summary": "VMP-MYSQL-01",
"issuelinks": [
{
"type": {
"name": "Relates",
"inward": "relates to",
"outward": "relates to"
},
"inwardIssue": {
"key": "CMDB-825"
},
"outwardIssue": "CMDB-825"
}
],
"customfield_10600": "VMP-MYSQL-01"
}
}
]
}
The error I get is:
{
"issues": [],
"errors": [
{
"status": 400,
"elementErrors": {
"errorMessages": [],
"errors": {
"issuelinks": "Field does not support update 'issuelinks'"
}
},
"failedElementNumber": 0
}
]
}
Does the API support the creation of Linked Issue at creation? Using the GUI works.
Jira is running v6.2.

Since this question is a bit older, I've been experiencing same issue as you. After some searching I found that instead of fields you can use update in the json you send to server.
Alternatively, you can use issueLink method to add links after creating the issue.
Complete code to create an issue with a link to a different issue:
{
"fields": {
"summary": "Sample Issue",
"project": {
"id": 14505
},
"issuetype": {
"id": 11002
}
},
"update": {
"issuelinks": [
{
"add": {
"type": {
"name": "Relates"
},
"inwardIssue": {
"key": "PRJ-1"
}
}
}
]
}
}

This will solve your problem. This will create an issue with one jira issue linked to it.
key is a project key,
Blocks or related to whichever you want.
put below json into http://jsonlint.com/. It will do proper formatting.
{
"fields": {
"summary": "Test Adapter",
"project": {
"key": "WFM"
},
"description": "Testing of Jira from Adapter",
"issuetype": {
"name": "Bug"
},
"update": {
"issuelinks": [{
"add": {
"type": {
"name": "Blocks",
"inward": "is blocked by",
"outward": "blocks"
},
"outwardIssue": {
"key": "WFM-28",
"fields": {
"summary": "Test Adapter"
}
}
}
}]
}
}
}

Related

Whatsapp API (#132000) Number of parameters does not match the expected number of params

I created below template in Whatsapp API. And I want to set the parameter value in the API call. What is the correct payload ? I have been following the Meta docs and trying but everytime I get error. Please Help.
Template:
You order # {{1}} is received successfully.
I used this payload:
{
"messaging_product": "whatsapp",
"to": "918456712349",
"type": "template",
"template": {
"name": "order_notification",
"language": {
"code": "en_US"
}
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "135345345"
}
]
}
]
}
But I am still getting this error
{
"error": {
"message": "(#132000) Number of parameters does not match the expected number of params",
"type": "OAuthException",
"code": 132000,
"error_data": {
"messaging_product": "whatsapp",
"details": "body: number of localizable_params (0) does not match the expected number of params (1)"
},
"error_subcode": 2494002,
"fbtrace_id": "AzPa-uWXctIcdNVu0Lf3Fic"
}
}
The issue due to closing the template object then opening a new component object.
make the component object inside the template object and it will be fixed
{
"messaging_product": "whatsapp",
"to": "918456712349",
"type": "template",
"template": {
"name": "order_notification",
"language": {
"code": "en_US"
}
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "135345345"
}
]
}
]
}
}
change in parameter type "header", this code run for me:
{
"messaging_product": "whatsapp",
"to": "918456712349",
"type": "template",
"template": {
"name": "order_notification",
"language": {
"code": "en_US"
},
"components": [
{
"type": "header",
"parameters": [
{
"type": "text",
"text": "xxxxxxx"
}
]
}
]
}
}
Looks like the template is expecting 1 parameter, which is not being provided.
You can look at the documentation and example here.
It includes a working example.

GA4 data api - (not set) in custom dimensions

We are currently using GA4 data API and faced the issue when custom dimensions returns value "(not set)".
We were using the following article to set custom dimension for the session count, but we still receiving "(not set)" values.
Example of request:
{
"dateRanges": [
{
"startDate": "2021-09-01",
"endDate": "2021-09-05"
}
],
"offset": 0,
"limit": 100,
"dimensionFilter": {
"filter": {
"fieldName": "eventName",
"stringFilter": {
"matchType": 1,
"value": "screen_view",
"caseSensitive": true
}
}
},
"dimensions": [
{
"name": "customUser:applicationID"
},
{
"name": "customEvent:ga_session_number"
},
{
"name": "dateHour"
},
{
"name": "platform"
},
{
"name": "sessionSource"
},
{
"name": "sessionMedium"
},
{
"name": "sessionCampaignName"
},
{
"name": "deviceCategory"
}
],
"metrics": [
{
"name": "userEngagementDuration"
}
]
}
Does anybody have any idea why it may happen?

Logic App with azure monitor and conditions

I create a workflow with logicAPP. The goal is to notify a team when patch is missing for VM. I use azure monitor in the logic app to set the query. I decided to put after the Azure Monitor , a condition to know if the query table is empty or have data. if the table is empty, the logix is true , so it does'nt send notification, and when its false , it sends notification.
When I run , I got a logic errors. Normally , the table has not data but after condition , the function empty([my_table]) returns false and sends me notification with the result ("The query yielded no data")
what is the problem ??
Thanks
Based on the above shared requirement we have created the logic app & tested it our local environment , it is working fine.
Below is the complete logic code :
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Condition_2": {
"actions": {
"Terminate_2": {
"inputs": {
"runStatus": "Cancelled"
},
"runAfter": {},
"type": "Terminate"
}
},
"else": {
"actions": {
"Send_an_email_(V2)_2": {
"inputs": {
"body": {
"Body": "<p>#{base64ToString(body('Run_query_and_visualize_results')?['body'])}</p>",
"Subject": "list of vm from update management ",
"To": "<UserEmailId>"
},
"host": {
"connection": {
"name": "#parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {},
"type": "ApiConnection"
}
}
},
"expression": {
"and": [
{
"equals": [
"#length(body('Run_query_and_visualize_results')?['body'])",
0
]
}
]
},
"runAfter": {
"Run_query_and_visualize_results": [
"Succeeded"
]
},
"type": "If"
},
"Run_query_and_visualize_results": {
"inputs": {
"body": "Update\n| where Classification == 'Security Updates' or Classification == 'Critical Updates'\n| where UpdateState == 'Needed'\n| summarize by Computer,ResourceGroup,Classification,UpdateState\n|sort by Computer",
"host": {
"connection": {
"name": "#parameters('$connections')['azuremonitorlogs']['connectionId']"
}
},
"method": "post",
"path": "/visualizeQuery",
"queries": {
"resourcegroups": "<Resource_group_Name",
"resourcename": "<log analytics workspacename",
"resourcetype": "Log Analytics Workspace",
"subscriptions": "<subcription_id>",
"timerange": "Last 12 hours",
"visType": "Html Table"
}
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Hour",
"interval": 3
},
"recurrence": {
"frequency": "Hour",
"interval": 3
},
"type": "Recurrence"
}
}
},
"parameters": {
"$connections": {
"value": {
"azuremonitorlogs": {
"connectionId": "/subscriptions/<subcription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/connections/azuremonitorlogs",
"connectionName": "azuremonitorlogs",
"id": "/subscriptions/<subcription-id>/providers/Microsoft.Web/locations/northcentralus/managedApis/azuremonitorlogs"
},
"office365": {
"connectionId": "/subscriptions/<subcription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"id": "/subscriptions/<subcription-id>/providers/Microsoft.Web/locations/northcentralus/managedApis/office365"
}
}
}
}
}
please find the reference output of the above logic sample run :

Azure Policy (deployifnotexists) not behaving as expected

This is my first post here. What I'm trying to do in Azure is deployifnotexists for storage accounts if certain settings are not enabled. I've attached my code. What I want to do is this:
Check for secure transfer being enabled
Check for TLS1_2 only
Check the FW
On the FW, have the Azure Services accepted (e.g. nsg flow logs etc)
If any of those conditions are not met, then deploy them through the ARM template. What is catching me is that I have intentionally put in bad settings to see it work and it will not say that they are non-compliant.
{
"mode": "All",
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Storage/storageAccounts"
},
"then": {
"effect": "deployIfNotExists",
"details": {
"type": "Microsoft.Storage/storageAccounts",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Storage/storageAccounts/supportsHttpsTrafficOnly",
"equals": true
},
{
"field": "Microsoft.Storage/storageAccounts/minimumTlsVersion",
"equals": "TLS1_2"
},
{
"field": "Microsoft.Storage/storageAccounts/networkAcls.defaultAction",
"equals": "deny"
},
{
"field": "Microsoft.Storage/storageAccounts/networkAcls.bypass",
"contains": "AzureServices"
}
]
},
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "String",
"metadata": {
"description": "storageAccountName"
}
},
"location": {
"type": "String",
"metadata": {
"description": "location"
}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"properties": {
"minimumTlsVersion": "TLS1_2",
"networkAcls": {
"bypass": "AzureServices",
"defaultAction": "Deny"
},
"supportsHttpsTrafficOnly": true
}
}
],
"outputs": {}
},
"parameters": {
"storageAccountName": {
"value": "[field('Name')]"
},
"location": {
"value": "[field('location')]"
}
}
}
}
}
}
},
"parameters": {}
}
Thanks everyone
So through further reading and talking with more experienced colleagues I've determined that "deployIfNotExists" conditions are not to be used for a resources own settings.
By that I mean I cannot "deployIfNotExists" to a storage accounts storage account settings (as above) but i could deploy diagnostic logging to a SA. I am closing this question. I will try append and if I do anything good I'll loop it back in to this question for keen eyes.

Creating a Mango query selector for element that do NOT match

I have a user like so:
{
"_id": "u88888",
"_rev": "27-9f205fb7496645be2f3d717fff376d73",
"name": "Test Testerson",
"type": "user",
"role": "boss",
"training": [
{
"id": "11111",
"name": "training 1"
},
{
"id": "33333",
"name": "training 3"
}
]
}
I'm trying to run a query to find the following:
Is a type, "user"
Has a role of "boss"
Does not have the training of id: "11111"
I do the following selector, however, this user comes up and I'm not sure why:
selector:{
"$and": [
{ "type": "user" },
{ "role": "boss" },
{ "training": { "$ne": { "id": "11111" } } }
]
}
Found an answer. This ended up working:
{ training: { $not: {$elemMatch: {id: "11111" } } }