Autodesk Forge: Download checklist attachment - c#

When I retrieve a checklist instance, I got the following section related to attachment.
{
"type": "instance_item_attachments",
"id": "5a0a2acf-b02a-4b88-86cc-962c3831bdee",
"attributes": {
"name": "6856ad10-6ab0-11e9-9150-9fda3da0626e.png",
"attachmentType": "OSS",
"mimeType": "image/png",
"uploadStatus": "COMPLETED",
"urns": [
{
"urn": "urn:adsk.wipprod:fs.file:vf.gy4mB910SneymU86Gc4O0A?version=1",
"type": "WIP"
},
{
"urn": "urn:adsk.objects:os.object:wip.dm.prod/ede3de59-1b68-485c-82fe-f1f2af3442fe.png",
"type": "OSS"
},
{
"urn": "urn:adsk.checklists.cs.attachment:58b8afcf-d7cd-49ad-aa10-78c50610761b/5a0a2acf-b02a-4b88-86cc-962c3831bdee",
"type": "CHECKLIST"
}
],
"createdAt": "2019-04-29T18:55:51.334Z",
"updatedAt": "2019-04-29T18:55:54.137Z",
"createdBy": "TAKCJQU6HGXW",
"modifiedBy": "TAKCJQU6HGXW",
"permittedActions": [
"canArchive",
"canEdit"
],
"permittedAttributes": [
"mimeType",
"uploadStatus"
]
},
"links": {
"self": "/containers/58b8afcf-d7cd-49ad-aa10-78c50610761b/instance_item_attachments/5a0a2acf-b02a-4b88-86cc-962c3831bdee"
},
"relationships": {
"container": {
"meta": {
"relation": "primary",
"readOnly": false
},
"links": {
"self": "/containers/58b8afcf-d7cd-49ad-aa10-78c50610761b/instance_item_attachments/5a0a2acf-b02a-4b88-86cc-962c3831bdee/relationships/container",
"related": "/containers/58b8afcf-d7cd-49ad-aa10-78c50610761b/instance_item_attachments/5a0a2acf-b02a-4b88-86cc-962c3831bdee/container"
},
"data": {
"type": "containers",
"id": "58b8afcf-d7cd-49ad-aa10-78c50610761b"
}
},
"item": {
"meta": {
"relation": "primary",
"readOnly": false
},
"links": {
"self": "/containers/58b8afcf-d7cd-49ad-aa10-78c50610761b/instance_item_attachments/5a0a2acf-b02a-4b88-86cc-962c3831bdee/relationships/item",
"related": "/containers/58b8afcf-d7cd-49ad-aa10-78c50610761b/instance_item_attachments/5a0a2acf-b02a-4b88-86cc-962c3831bdee/item"
},
"data": null
}
}
}
Now, I want to download this attachment, the provided URN is: wip.dm.prod/ede3de59-1b68-485c-82fe-f1f2af3442fe.png
If I try to access it using the following link, it says not found
developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/b30e3ffe-333b-446c-b834-e2f2141096b4.png
However, if I changed the URL a bit (by adding objects), it works fine.
developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/b30e3ffe-333b-446c-b834-e2f2141096b4.png
Am I doing something wrong here? or this is a bug in the provided urn?

Adding to Adam Nagy reply, you would need to break the URN. From your original question:
urn:adsk.objects:os.object:wip.dm.prod/ede3de59-1b68-485c-82fe-f1f2af3442fe.png
In .NET you can try (using System.Linq):
string bucketKey = urn.Split("/").First().Split(":").Last();
string objectName = urn.Split("/").Last();
Then rebuild as:
string attachemtnUrl = string.Format("{0}/oss/v2/buckets/{1}/objects/{2}", BASE_URL, bucketKey, objectName);
And you'll also need the Authorization header with a valid access token.

The id / urn of an object in OSS (Object Storage Service) contains the bucket name and object name after the "urn:adsk.objects:os.object:" section.
There is a tutorial on downloading a file https://forge.autodesk.com/en/docs/data/v2/tutorials/download-file/
It shows that the reply concerning an item contains both the id and the actual URL of the download link under the storage section:
"storage": {
"data": {
"type": "objects",
"id": "urn:adsk.objects:os.object:wip.dm.prod/977d69b1-43e7-40fa-8ece-6ec4602892f3.rvt"
},
"meta": {
"link": {
"href": "https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/977d69b1-43e7-40fa-8ece-6ec4602892f3.rvt"
}
}
}
There you can see the connection between the id and the URL you can use to download the file

Related

Trying to setup diagnostic settings for activity logs in ARM template

I've been trying to create a template for a logger function app in Azure, the basic idea is that it'll forward all activity log category info along with all audit log info using event hubs as triggers, I've gotten down most of the template, but I keep hitting the following error when it comes to the diagnostic settings part:
The resource type '/' does not support diagnostic settings.
Is there something I'm doing wrong? I've only started working with azure for a short while, and am afraid I'm misunderstanding how diagnostic settings are created in an ARM template. I can't seem to find any template or documentation online about this, and am at a loss...
Here's an excerpt:
...
"variables": {
"eventHubNamespaceName": "azure-logger",
"auditEventHubName": "[concat(variables('eventHubNamespaceName'), '/', 'audit-logs')]",
"activityEventHubName": "[concat(variables('eventHubNamespaceName'), '/', 'activity-logs')]",
"authRuleResourceId": "[resourceId('Microsoft.Eventhub/namespaces/authorizationRules', variables('eventHubNamespaceName'), 'RootManageSharedAccessKey')]",
"auditAuthorizationRuleId": "[resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', variables('eventHubNamespaceName') , 'audit-logs', 'default')]",
"activityAuthorizationRuleId": "[resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', variables('eventHubNamespaceName') , 'activity-logs', 'default')]"
},
"resources": [
{
"name": "[variables('eventHubNamespaceName')]",
"type": "Microsoft.EventHub/namespaces",
"apiVersion": "2021-06-01-preview",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"identity": {
"type": "SystemAssigned"
},
"properties": {
"status": "Active"
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces/eventhubs",
"apiVersion": "2021-06-01-preview",
"name": "[concat(variables('eventHubNamespaceName'), '/', 'audit-logs')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', variables('eventHubNamespaceName'))]"
],
"properties": {
"messageRetentionInDays": 1,
"partitionCount": 1
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
"apiVersion": "2021-06-01-preview",
"name": "[concat(variables('eventHubNamespaceName'), '/', 'audit-logs','/','default')]",
"properties": {
"rights": [ "Manage", "Listen", "Send" ]
},
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('eventHubNamespaceName'), 'audit-logs')]"
]
}
]
},
{
"type": "Microsoft.EventHub/namespaces/eventhubs",
"apiVersion": "2021-06-01-preview",
"name": "[concat(variables('eventHubNamespaceName'), '/', 'activity-logs')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', variables('eventHubNamespaceName'))]"
],
"properties": {
"messageRetentionInDays": 1,
"partitionCount": 1
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
"apiVersion": "2021-06-01-preview",
"name": "[concat(variables('eventHubNamespaceName'), '/', 'activity-logs','/','default')]",
"properties": {
"rights": [ "Manage", "Listen", "Send" ]
},
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('eventHubNamespaceName'), 'activity-logs')]"
]
}
]
}
]
},
{
"type": "Microsoft.Insights/diagnosticSettings",
"apiVersion": "2017-05-01-preview",
"name": "[concat(variables('eventHubNamespaceName'),'activity-logs')]",
"properties": {
"eventHubName": "activity-logs",
"eventHubAuthorizationRuleId": "[variables('activityAuthorizationRuleId')]",
"logs": [
{
"category": "Administrative",
"enabled": true
},
{
"category": "Security",
"enabled": true
},
{
"category": "ServiceHealth",
"enabled": true
},
{
"category": "Alert",
"enabled": true
},
{
"category": "Recommendation",
"enabled": true
},
{
"category": "Policy",
"enabled": true
},
{
"category": "Autoscale",
"enabled": true
},
{
"category": "ResourceHealth",
"enabled": true
}
]
}
}
]
...```
Diagnostic settings for Activity logs are created for a subscription, not for a resource group like settings for Azure resources. Therefore, when you check the Diagnostic setting for Activity log in this document, you will find that you can deploy Azure Resource Manager templates using any valid method including PowerShell and CLI. Diagnostic settings for Activity log must deploy to a subscription using az deployment create for CLI or New-AzDeployment for PowerShell.
And the template should look like as following :
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"settingName": {
"type": "String"
},
"workspaceId": {
"type": "String"
},
"storageAccountId": {
"type": "String"
},
"eventHubAuthorizationRuleId": {
"type": "String"
},
"eventHubName": {
"type": "String"
}
},
"resources": [
{
"type": "Microsoft.Insights/diagnosticSettings",
"apiVersion": "2017-05-01-preview",
"name": "[parameters('settingName')]",
"properties": {
"workspaceId": "[parameters('workspaceId')]",
"storageAccountId": "[parameters('storageAccountId')]",
"eventHubAuthorizationRuleId": "[parameters('eventHubAuthorizationRuleId')]",
"eventHubName": "[parameters('eventHubName')]",
"logs": [
{
"category": "Administrative",
"enabled": true
},
{
"category": "Security",
"enabled": true
},
{
"category": "ServiceHealth",
"enabled": true
},
{
"category": "Alert",
"enabled": true
},
{
"category": "Recommendation",
"enabled": true
},
{
"category": "Policy",
"enabled": true
},
{
"category": "Autoscale",
"enabled": true
},
{
"category": "ResourceHealth",
"enabled": true
}
]
}
}
]
}
You should have a Parameter file if you follow the above template.
Also note that when virtual networks are enabled Diagnostic Settings can't access Event Hubs resources. You have to enable the Allow trusted Microsoft services to bypass this firewall setting in Event Hub, so that Diagnostic Settings (Azure Monitor Services) is granted access to your Event Hubs resources.

Google API Explorer doesn't create Compute Engine VM instance

as in title, I am trying to use Google API Explorer to run vm instance. I am using instances.insert for this, but I can't get it to work. After successfuly executing the call I can not see any newly creted vm instance in https://console.cloud.google.com/compute/instances
The request I am trying to execute is copied from Equivalent REST request in Google Cloud Console Create an instance web page :
{
"name": "some-name",
"machineType": "projects/my-project-id/zones/europe-west3-c/machineTypes/f1-micro",
"displayDevice": {
"enableDisplay": false
},
"metadata": {
"items": [
{
"key": "startup-script",
"value": "#! /bin/bash\necho hello\nEOF"
}
]
},
"tags": {
"items": []
},
"disks": [
{
"type": "PERSISTENT",
"boot": true,
"mode": "READ_WRITE",
"autoDelete": true,
"deviceName": "some-name",
"initializeParams": {
"sourceImage": "projects/debian-cloud/global/images/debian-10-buster-v20200910",
"diskType": "projects/my-project-id/zones/europe-west3-c/diskTypes/pd-standard",
"diskSizeGb": "10",
"labels": {}
},
"diskEncryptionKey": {}
}
],
"canIpForward": false,
"networkInterfaces": [
{
"subnetwork": "projects/my-project-id/regions/europe-west3/subnetworks/default",
"accessConfigs": [
{
"name": "External NAT",
"type": "ONE_TO_ONE_NAT",
"networkTier": "PREMIUM"
}
],
"aliasIpRanges": []
}
],
"description": "",
"labels": {},
"scheduling": {
"preemptible": false,
"onHostMaintenance": "MIGRATE",
"automaticRestart": true,
"nodeAffinities": []
},
"deletionProtection": false,
"reservationAffinity": {
"consumeReservationType": "ANY_RESERVATION"
},
"serviceAccounts": [
{
"email": "some-number-compute#developer.gserviceaccount.com",
"scopes": [
"https://www.googleapis.com/auth/cloud-platform"
]
}
],
"shieldedInstanceConfig": {
"enableSecureBoot": false,
"enableVtpm": true,
"enableIntegrityMonitoring": true
},
"confidentialInstanceConfig": {
"enableConfidentialCompute": false
}
}
Here is the response with status 200
{
"id": "2981010757915612255",
"name": "operation-1602235056020-5b1396b5c5cee-e0e30499-4d06ce75",
"zone": "https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c",
"operationType": "insert",
"targetLink": "https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c/instances/ams2-linux-race-1",
"targetId": "1541614827291382879",
"status": "RUNNING",
"user": "email#gmail.com",
"progress": 0,
"insertTime": "2020-10-09T02:17:36.818-07:00",
"startTime": "2020-10-09T02:17:36.821-07:00",
"selfLink": "https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c/operations/operation-1602235056020-5b1396b5c5cee-e0e30499-4d06ce75",
"kind": "compute#operation"
}
I have the same issue with C# code example from https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert#examples
I can execute the same request without errors and in response I am getting this
{
"clientOperationId":null,
"creationTimestamp":null,
"description":null,
"endTime":null,
"error":null,
"httpErrorMessage":null,
"httpErrorStatusCode":null,
"id":3283200477858999168,
"insertTime":"2020-10-09T00:46:55.187-07:00",
"kind":"compute#operation",
"name":"operation-1602229614262-5b1382701b989-381126a6-cc145485",
"operationType":"insert",
"progress":0,
"region":null,
"selfLink":"https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c/operations/operation-1602229614262-5b1382701b989-381126a6-cc145485",
"startTime":"2020-10-09T00:46:55.189-07:00",
"status":"RUNNING",
"statusMessage":null,
"targetId":2365846324436118401,
"targetLink":"https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c/instances/some-name",
"user":"email#gmail.com",
"warnings":null,
"zone":"https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c",
"ETag":null
}
but I can't see any new instance beeing created...
Does any one know what is the issue here?
The Compute Engine API is enabled. Result of gcloud services list:
NAME TITLE
...
compute.googleapis.com Compute Engine API
...
Can you please double check if Compute Engine Api is enabled and post the result in your question.
gcloud services list
I believe your Compute Engine Api is not enabled.

Message card rendering issue in bot framework v3

I have a message card payload pushed from service now which is not rendering properly on MS Teams through bot framework. It only displays the content but not the button.Below is the payload, pls suggest what could be the issue.
BotFramework:V3
.Net SDK
Bot Builder package:3.12.2.4
Bot Connector:3.12.2.4
Bot.Connector.Teams:0.9.0
{
"contentType": "application/vnd.microsoft.teams.card.o365connector",
"content": {
"#type": "MessageCard",
"#context": "http://schema.org/extensions",
"title": "Incident Updated - INC0010010",
"summary": "Incident Updated - INC0010010",
"themeColor": "D1222B",
"sections": [
{
"title": "",
"text": "",
"activityTitle": "",
"activitySubtitle": "",
"activityText": "",
"facts": [
{
"name": "Category",
"value": "Software"
},
{
"name": "State",
"value": "New"
},
{
"name": "Priority",
"value": "5 - Planning"
},
{
"name": "Assignment group",
"value": "Software"
}
]
},
{
"text": "Please check the details"
}
],
"potentialAction": [
{
"#type": "OpenUri",
"name": "View Incident in ServiceNow",
"targets": [
{
"os": "default",
"uri": "https://dev62584.service-now.com/incident.do?sys_id=XXXXXXX&sysparm_stack=incident_list.do?sysparm_query=active=true"
},
{
"os": "iOS",
"uri": "https://dev62584.service-now.com/incident.do?sys_id=XXXXXXX&sysparm_stack=incident_list.do?sysparm_query=active=true"
},
{
"os": "android",
"uri": "https://dev62584.service-now.com/incident.do?sys_id=XXXXXXX&sysparm_stack=incident_list.do?sysparm_query=active=true"
},
{
"os": "windows",
"uri": "https://dev62584.service-now.com/incident.do?sys_id=7ec9865adb711010fcff8809489619b4&sysparm_stack=incident_list.do?sysparm_query=active=true"
}
]
}
]
}
}
Microsoft Troubleshooting and recommendation:
We were finally able to repro this issue. It is a bug in the team's scope and doesn't repro in the personal scope. An easy way to unblock you would be to add in the potentialAction section an #id field like so:
"potentialAction": [
{
"#id":"1",
"#type": "OpenUri",
Nothing stands out as a bug in your code or problem with your configuration. Linking to the GitHub issue where it is being investigated/troubleshot:
https://github.com/microsoft/BotBuilder-V3/issues/208

C#, JSON, Deserialize into DataTable

I have my JSON as
{{
"attributes": {
"type": "User",
"url": "/services/data/v44.0/sobjects/User/0052F000002bO32QAE"
},
"Name": "demo Site Guest User",
"UserType": "Guest",
"Profile": {
"attributes": {
"type": "Profile",
"url": "/services/data/v44.0/sobjects/Profile/00e2F000000DuoFQAS"
},
"Id": "00e2F000000DuoFQAS",
"Name": "demo Profile"
}
}}
{{
"attributes": {
"type": "User",
"url": "/services/data/v44.0/sobjects/User/00541000006I1JyAAK"
},
"Name": "Scheduler Site Guest User",
"UserType": "Guest",
"Profile": {
"attributes": {
"type": "Profile",
"url": "/services/data/v44.0/sobjects/Profile/00e41000000GhKdAAK"
},
"Id": "00e41000000GhKdAAK",
"Name": "Scheduler Profile"
}
}}
In the above JSON, I want to fetch parent elements 'Name' and 'UserType' and child elements'Id' and 'Name' and convert into datatable. These parent and child elements are anonymous so I can't create classes for those.
I got up to here
dynamic responseRecs = (responseDetails.records as IEnumerable<object>).Cast<object>().ToList();
which is giving me the response but not sure how to loop through the dynamic and get parent and child line items (ignoring the type and url) so that I can build a datatable.
Any help will be greatly appreciated. Thanks

Create DropDown list for jira custom field in REST API

I'm trying to retrieve the available options for fields through the Jira REST API but I'm getting stuck on the custom fields.
A normal field returns something like this:
{[priority, {
"required": false,
"schema": {
"type": "priority",
"system": "priority"
},
"name": "Priority",
"key": "priority",
"hasDefaultValue": true,
"operations": [
"set"
],
"allowedValues": [
{
"self": "https://inn-inw.atlassian.net/rest/api/2/priority/1",
"iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/highest.svg",
"name": "Highest",
"id": "1"
},
{
"self": "https://inn-inw.atlassian.net/rest/api/2/priority/2",
"iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/high.svg",
"name": "High",
"id": "2"
},
{
"self": "https://inn-inw.atlassian.net/rest/api/2/priority/3",
"iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/medium.svg",
"name": "Medium",
"id": "3"
},
{
"self": "https://inn-inw.atlassian.net/rest/api/2/priority/4",
"iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/low.svg",
"name": "Low",
"id": "4"
},
{
"self": "https://inn-inw.atlassian.net/rest/api/2/priority/5",
"iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/lowest.svg",
"name": "Lowest",
"id": "5"
}
],
"defaultValue": {
"self": "https://inn-inw.atlassian.net/rest/api/2/priority/3",
"iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/medium.svg",
"name": "Medium",
"id": "3"
}
}]}
The custom fields on the other hand return a much "smaller" set!
"Sprint" Custom Field:
{[customfield_10113, {
"required": false,
"schema": {
"type": "array",
"items": "string",
"custom": "com.pyxis.greenhopper.jira:gh-sprint",
"customId": 10113
},
"name": "Sprint",
"key": "customfield_10113",
"hasDefaultValue": false,
"operations": [
"set"
]
}]}
"Epic Link"
{[customfield_10006, {
"required": false,
"schema": {
"type": "any",
"custom": "com.pyxis.greenhopper.jira:gh-epic-link",
"customId": 10006
},
"name": "Epic Link",
"key": "customfield_10006",
"hasDefaultValue": false,
"operations": [
"set"
]
}]}
As you can see there are no options available, but i know that there are.
How can I get to these values through rest?
I have tried checking the request that the cloud server makes but it's pretty different for each of the custom fields and i cannot find a relation between them. For example:
To get the sprint possible values: https://inn-inw.atlassian.net/rest/greenhopper/1.0/sprint/picker?query=
and to get the Epic values: https://inn-inw.atlassian.net/rest/greenhopper/1.0/epics
I'm trying to make things as clean as possible and I would prefer not to hard code the request, specially because i would probably need to update the code every time a new custom field is created.
PS: I have tried some of the solutions presented in other questions but couldn't find one that fits what i need. eg: https://inn-inw.atlassian.net//rest/api/2/issue/createmeta?projectKeys=PROJKEY&issuetypeNames=Bug&expand=projects.issuetypes.fields returns only the short description that is displayed above.

Categories

Resources