Send Jira Issue Description text as ADF table in Jira REST API - jira

I am trying to update an issue description by sending an ADF table. My javascript code is as follows.
{
"fields" : {
"description": {
"version": 1,
"type": "doc",
"content": [
{
"type": "table",
"attrs": {
"isNumberColumnEnabled": false,
"layout": "default"
},
"content": [
{
"type": "tableRow",
"content": [
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": " Row one, cell one"
}]
}]
},
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Row one, cell two"
} ]
}]
}]
}]
}]
}
}
}
The error that I get back is "description":"Operation value must be a string". Not sure what I am doing wrong as it looks like I have the ADF formatting correct.
This is calling jira cloud via the rest api.

Found the answer. The URL must be version 3 of the API. Just have "latest" will not work. Example:
https://mycompay.atlassian.net/rest/api/3/issue/45379
and not
https://mycompany.atlassian.net/rest/api/latest/issue/45379

Related

How do you get the side color bar to work for Slack notification attachments?

I'm POSTing the following test json to a Slack Webhook Url:
{
"attachments": [
{
"blocks": [
{
"type": "divider"
},
{
"text": {
"text": "This is error 1",
"type": "plain_text"
},
"type": "section"
},
{
"type": "divider"
},
{
"text": {
"text": "This is error 2",
"type": "plain_text"
},
"type": "section"
},
{
"type": "divider"
},
{
"text": {
"text": "This is error 3",
"type": "plain_text"
},
"type": "section"
}
],
"color": "danger"
}
],
"blocks": [
{
"text": {
"text": "*Failed*\nDeploy <https://google.com|Test>\nTotal tests: 75 Passed: 75 Total time: 54.1872 Seconds\nError Messages:",
"type": "mrkdwn"
},
"type": "section"
}
]
}
As you can see in the payload, I'm setting "color": "danger" in the attachment object, which should result in a red color bar on the notification according to Slack's documentation. However, the Slack notification just has the default gray color bar. What am I doing wrong?

Time Series Insights not showing sub-object properties of a key/value pair

I have an application that is pushing data into IoT Hub which is being used as a data source for TSI. Below is an example message:
{
"EnqueuedTimeUtc": "2021-06-17T22:00:47.2170000Z",
"Properties": {},
"SystemProperties": {
"connectionDeviceId": "Device1",
"connectionAuthMethod": "{\"scope\":\"device\",\"type\":\"sas\",\"issuer\":\"iothub\",\"acceptingIpFilterRule\":null}",
"connectionDeviceGenerationId": "637425408342887985",
"contentType": "application/json",
"contentEncoding": "utf-8",
"enqueuedTime": "2021-06-17T22:00:47.2170000Z"
},
"Body": {
"topic": {
"namespace": "spBv1.0",
"edgeNodeDescriptor": "Routed Group/E2",
"groupId": "Routed Group",
"edgeNodeId": "E2",
"deviceId": "D2",
"type": "DBIRTH"
},
"payload": {
"timestamp": "2021-06-17T22:00:47.082Z",
"metrics": [{
"name": "Ramp1",
"timestamp": "2021-06-17T22:00:47.082Z",
"dataType": "Int32",
"metaData": {},
"properties": {
"Quality": {
"type": "Int32",
"value": 192
},
"My Property": {
"type": "String",
"value": "{\"\":\"\"}"
}
},
"value": 77
}],
"seq": 1
}
}
}
I found documentation showing that my array of 'metrics' is supported as shown here:
https://learn.microsoft.com/en-us/azure/time-series-insights/concepts-json-flattening-escaping-rules
With this message, I can see 'Ramp1' show up in TSI with a value and timestamp as expected. However, the 'properties' under each metric do not show up. In this example that is 'Quality' and 'My Property'. Is there a way to get this data into TSI with an association to 'Ramp1'?

AWS CDK - trying to add Input Transformer using class aws_cdk.aws_events.RuleTargetInputProperties

As the title mentions, I'm trying to replicate a Input Transformer using RuleTargetInputProperties but i can't seem to find any examples or get the correct format to input.
The template i'm trying to replicate is the following:
InputTemplate: |
{
"sourceVersion": <sourceVersion>,
"artifactsOverride": {"type": "NO_ARTIFACTS"},
"environmentVariablesOverride": [
{
"name": "PULL_REQUEST_ID",
"value": <pullRequestId>,
"type": "PLAINTEXT"
},
{
"name": "REPOSITORY_NAME",
"value": <repositoryName>,
"type": "PLAINTEXT"
},
{
"name": "SOURCE_COMMIT",
"value": <sourceCommit>,
"type": "PLAINTEXT"
},
{
"name": "DESTINATION_COMMIT",
"value": <destinationCommit>,
"type": "PLAINTEXT"
},
{
"name" : "REVISION_ID",
"value": <revisionId>,
"type": "PLAINTEXT"
}
]
}
InputPathsMap:
sourceVersion: "$.detail.sourceCommit"
pullRequestId: "$.detail.pullRequestId"
repositoryName: "$.detail.repositoryNames[0]"
sourceCommit: "$.detail.sourceCommit"
destinationCommit: "$.detail.destinationCommit"
revisionId: "$.detail.revisionId"
I've tried with RuleTargetInput, but this doesn't give me the correct template
on_pr_rule = repo.on_pull_request_state_change("PR",
target=targets.CodeBuildProject(project,
dead_letter_queue=dead_letter_queue,
event=events.RuleTargetInput.from_object({
"sourceVersion": events.EventField.from_path("$.detail.sourceCommit"),
"pullRequestId": events.EventField.from_path("$.detail.pullRequestId"),
"repositoryName": events.EventField.from_path("$.detail.repositoryNames[0]"),
"sourceCommit": events.EventField.from_path("$.detail.sourceCommit"),
"destinationCommit": events.EventField.from_path("$.detail.destinationCommit"),
"revisionId": events.EventField.from_path("$.detail.revisionId")
})
)
)
InputTransformer:
InputPathsMap:
detail-sourceCommit: $.detail.sourceCommit
detail-pullRequestId: $.detail.pullRequestId
detail-repositoryNames-0-: $.detail.repositoryNames[0]
detail-destinationCommit: $.detail.destinationCommit
detail-revisionId: $.detail.revisionId
InputTemplate: '{"sourceVersion":<detail-sourceCommit>,"pullRequestId":<detail-pullRequestId>,"repositoryName":<detail-repositoryNames-0->,"sourceCommit":<detail-sourceCommit>,"destinationCommit":<detail-destinationCommit>,"revisionId":<detail-revisionId>}'
Has anyone had any experience with adding a template as such using RuleTargetInputProperties?
From the input, I am guessing you are working on the PR workflow. This is what I ended up with .
_pr_build_events_input = events.RuleTargetInput.from_object({
"sourceVersion": events.EventField.from_path("$.detail.sourceCommit"),
"artifactsOverride": {"type": "NO_ARTIFACTS"},
"environmentVariablesOverride": [
{
"name": 'pullRequestId',
"value": EventField.from_path('$.detail.pullRequestId'),
"type": 'PLAINTEXT',
},
{
"name": 'repositoryName',
"value": EventField.from_path('$.detail.repositoryNames[0]'),
"type": 'PLAINTEXT',
},
{
"name": 'sourceCommit',
"value": EventField.from_path('$.detail.sourceCommit'),
"type": 'PLAINTEXT',
},
{
"name": 'destinationCommit',
"value": EventField.from_path('$.detail.destinationCommit'),
"type": 'PLAINTEXT',
},
{
"name": 'revisionId',
"value": EventField.from_path('$.detail.revisionId'),
"type": 'PLAINTEXT',
},
],
})

Create message in Exchange causes "UnableToDeserializePostBody"

I have some code that was working just fine a few months ago, but something in the Graph API has changed and this no longer works. I am trying to create a message in an existing folder, by doing a POST to this url:
https://graph.microsoft.com/v1.0/users/jjones#transend.onmicrosoft.com/mailFolders/AAMkADNjAAA=/messages
(folder id shortened)
The call fails with http error 400, and the returned error is "UnableToDeserializePostBody". The input json is shown below. By experimentation I was able to trace the problem specifically to "singleValueExtendedProperties". I normally put several properties there, but for this test I removed all but the one you see. I have tried other properties as well, they all fail. This seems like some stupid formatting error but I can't see it. Any help appreciated.
{
"subject": "Test again",
"Sender": {
"emailAddress": {
"name": "John Doe",
"address": "missing#domain.com"
}
},
"body": {
"contentType": "TEXT",
"content": "This is a text message."
},
"toRecipients": [
{
"emailAddress": {
"name": "Jane Smith",
"address": "missing#domain.com"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"name": "Bob Jones",
"address": "missing#domain.com"
}
}
],
"singleValueExtendedProperties": [
{
"propertyId": "SystemTime 0x0039",
"value": "1998-07-29T21:30:00.0000+00:00"
}
],
"importance": "normal"
}
The main problem here is you are specifying the property('propertyid') in singleValueExtendedProperties object is not valid. There are only 2 properties in singleValueExtendedProperties. One is id and the other is value.
Replace 'propertyId' with id.
I have tested it in POSTMAN with your payload changing the propertyId to id and it worked.
Request Body:-
{
"subject": "Test again",
"Sender": {
"emailAddress": {
"name": "John Doe",
"address": "missing#domain.com"
}
},
"body": {
"contentType": "TEXT",
"content": "This is a text message."
},
"toRecipients": [
{
"emailAddress": {
"name": "Jane Smith",
"address": "missing#domain.com"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"name": "Bob Jones",
"address": "missing#domain.com"
}
}
],
"singleValueExtendedProperties": [
{
"id": "SystemTime 0x0039",
"value": "1998-07-29T21:30:00.0000+00:00"
}
],
"importance": "normal"
}

Powerapps difficulty accessing JSON in collection

I'm having difficulty accessing data in a collection, via PowerApps.
I create the collection with this:
Collect(coll15,mt.GetAnswers("3b....da","application/json",{question:"eco"}))
Using Developer Tools -> Network tab -> Response body - the following JSON data is returned:
{
"answers": [
{
"answer": "This is the answer",
"questions": [
"Private vehicle eco renewal"
],
"score": 82.901087775826454
}
]
}
The collection is created.
I then add a gallery control to my page - however the only options I have to bind to the labels are: ThisItem.Value
If I try to enter ThisItem.Value.answer I get the error: Invalid use of '.'
If I enter ThisItem.answers.answer I get the error: Invalid name
This is the swagger file:
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "mt",
"description": "mt"
},
"host": "westus.api.cognitive.microsoft.com:443",
"basePath": "/",
"schemes": [
"https"
],
"consumes": [],
"produces": [
"application/json"
],
"paths": {
"/qnamaker/v2.0/knowledgebases/eeeee.....eeeee/generateAnswer": {
"post": {
"summary": "GetAnswers",
"description": "Get answers from qna",
"operationId": "GetAnswers",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"type": "object",
"properties": {
"question": {
"type": "string",
"description": "question",
"x-ms-summary": "question",
"title": "question",
"x-ms-visibility": ""
}
},
"default": {
"question": "hi"
},
"required": [
"question"
]
},
"required": true
}
],
"responses": {
"default": {
"description": "default",
"schema": {
"type": "string"
}
}
}
}
}
},
"definitions": {},
"parameters": {},
"responses": {},
"securityDefinitions": {
"api_key": {
"type": "apiKey",
"in": "header",
"name": "Ocp-Apim-Subscription-Key"
}
},
"security": [
{
"oauth2_auth": [
"Offline-Access"
]
}
],
"tags": []
}
Is there any way for me to access the answer text within the collection?
Thanks for any help,
Mark
The problem is that the response type for the operation in the connector definition is string:
"responses": {
"default": {
"description": "default",
"schema": {
"type": "string"
}
}
}
But your response is an object instead. If you update your custom connector to use a typed object instead, you should be able to access the response from the operation. Something along the lines of the schema below:
"responses": {
"default": {
"description": "default",
"schema": {
"type": "object",
"properties": {
"answers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"answer": {
"type": "string"
},
"questions": {
"type": "array",
"items": {
"type": "string"
}
},
"score": {
"type": "number",
"format": "float"
}
}
}
}
}
}
}
},
Notice that in the portal (web.powerapps.com), if you go to your custom connector definition, and select "Edit", you can go to the operation, and select the response you want to edit:
And then use the "Import from sample" option
With that, if you enter an example of a response from the API, it will create the schema for you (which is similar to the one I have above).

Resources