Autodesk Design Automation API DWG to PDF using Dropbox - dropbox-api

Hello I am struggling with finding a working example on how to convert a DWG file to a PDF file. I am using Autodesk Design Automation API and Dropbox. I try to use following command to place a WorkItem
{
"Arguments":{
"InputArguments":[
{
"Resource": "https://content.dropboxapi.com/2/files/download",
"Name": "HostDwg",
"Headers":[
{
"Name":"Authorization",
"Value":"Bearer xxxxxxxxxxxxxxxxxxxxxxxx"
},{
"Name":"Dropbox-API-Arg",
"Value" : {"path":"/original.dwg"}
}
]
}
],
"OutputArguments":[
{
"Name": "Result",
"HttpVerb": "PUT",
"Resource": "https://content.dropboxapi.com/2/files/upload",
"StorageProvider": "Generic",
"Headers":[
{
"Name":"Authorization",
"Value":"Bearer xxxxxxxxxxxxxx"
},{
"Name":"Dropbox-API-Arg",
"Value": {"path":"/test.pdf"}
}
]
}
]
}, "ActivityId": "PlotToPDF","Id": ""}
Unfortunately I get following Error message
An unexpected 'StartObject' node was found for property named 'Value' when reading from the JSON reader. A 'PrimitiveValue' node was expected.
I think it has to do with the second Header I have defined, to specify the file to be downloaded or uploaded. It is unclear to me how to set this value correct.
If Iam using dropbox api without Design Automation API this is working. I can define a Header named Dropbox-API-Arg and define to download/upload path.
Any help would be appreciated. Thankyou

We have improved Design Automation so that now using Dropbox-API-Arg header works both for upload and download. The following will convert a DWG to PDF in your dropbox account:
{
"Arguments": {
"InputArguments": [
{
"Resource": "https://content.dropboxapi.com/2/files/download",
"Name": "HostDwg",
"Headers" : [
{
"Name" : "Authorization",
"Value" : "Bearer ..."
},
{
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.dwg\"}"
}
]
}
],
"OutputArguments": [
{
"Name": "Result",
"HttpVerb": "POST",
"Resource": "https://content.dropboxapi.com/2/files/upload",
"Headers" : [
{
"Name" : "Authorization",
"Value" : "Bearer ..."
},
{
"Name" : "Content-Type",
"Value" : "application/octet-stream"
},
{
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.pdf\", \"mode\":\"add\"}"
}
]
}
]
},
"ActivityId": "PlotToPDF"
}

The problem is that we expect "Value" to be string and you are passing an object. Here's a working example:
{
"Arguments": {
"InputArguments": [
{
"Resource": "http://download.autodesk.com/us/samplefiles/acad/blocks_and_tables_-_imperial.dwg",
"Name": "HostDwg"
}
],
"OutputArguments": [
{
"Name": "Result",
"HttpVerb": "POST",
"Resource": "https://content.dropboxapi.com/2/files/upload",
"Headers" : [
{
"Name" : "Authorization",
"Value" : "Bearer ..."
},
{
"Name":"Content-Type",
"Value":"application/octet-stream"
},
{
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.pdf\", \"mode\":\"add\"}"
}
]
}
]
},
"ActivityId": "PlotToPDF"
}

EDITED
Either you can pass Dropbox-API-Arg header as below
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.pdf\", \"mode\":\"add\"}"
in the payload.
Or, passing arg url encoded string will also works.
Use following payload to work with Dropbox using Forge Design Automation.
You need to pass Arg parameter instead of ‘Dropbox-API-Arg’ header.
arg={"path":"/result.pdf"} encoded in URL as "arg=%7B%22path%22%3A%22%2Fresult.pdf%22%7D"
For example:
To post result.pdf in Dropbox.
{
"Arguments": {
"InputArguments": [
{
"Resource": "http://download.autodesk.com/us/samplefiles/acad/blocks_and_tables_-_metric.dwg",
"Name": "HostDwg"
}
],
"OutputArguments": [
{
"Name": "Result",
"HttpVerb": "POST",
"Resource": "https://content.dropboxapi.com/2/files/upload?arg=%7B%22path%22%3A%22%2Fresult.pdf%22%7D",
"StorageProvider": "Generic",
"Headers": [
{
"Name":"Authorization",
"Value":"Bearer blahblahblah"
},
{"Name":"Content-Type",
"Value":"application/octet-stream"
}
]
}
]
},
"ActivityId": "PlotToPDF"
}

Related

Adding multiple Principal values for KMS key

I want to add multiple Principal values for a KMS key using CloudFormation. This is a snippet of the code:
"KmsKeyManager": {
"Type": "String",
"Default": "user1,user2,user3"
}
"Principal": {
"AWS": {
"Fn::Split": [
",",
{
"Fn::Sub": [
"arn:aws:iam::${AWS::AccountId}:user/people/${rest}",
{
"rest": {
"Fn::Join": [
"",
[
"arn:aws:iam::",
{
"Ref": "AWS::AccountId"
},
":user/people/",
{
"Ref": "KmsKeyManager"
}
]
...
The ARN should be constructed as arn:aws:iam::12345678:user/people/user1 etc.
The template is accepted in the console, but when running I get the following error:
Resource handler returned message: "An ARN in the specified key policy is invalid.
I followed the answer here which resulted in the above error
CloudFormation Magic to Generate A List of ARNs from a List of Account Ids
Any idea where I am going wrong? CloudFormation is new to me, so the alternative is I create with 1 user and add new users manually.
Let me explain from the answer you linked. They use the string ":root,arn:aws:iam::" as a delimiter.
Therefore,
"Accounts" : {
"Type" : "CommaDelimitedList",
"Default" : "12222234,23333334,1122143234,..."
}
"rest": {
"Fn::Join": [
":root,arn:aws:iam::",
{ "Ref": "Accounts" }
]
}
gives rest like this.
12222234:root,arn:aws:iam::23333334:root,arn:aws:iam::1122143234
and this rest is substituted for ${rest} in "arn:aws:iam::${rest}:root" (This long string will be split finally with "Fn::Split".)
In your case, delimiter will be "arn:aws:iam::${AWS::AccountId}:user/people/".
This is also need to be joined:
{
"Fn::Join": [
"", [
"arn:aws:iam::",
{
"Ref": "AWS::AccountId"
},
":user/people/"
]
]
}
The total will be like:
"Fn::Sub": [
"arn:aws:iam::${AWS::AccountId}:user/people/${rest}",
{
"rest": {
"Fn::Join": [
"Fn::Join": [
"", [
"arn:aws:iam::",
{
"Ref": "AWS::AccountId"
},
":user/people/"
]
],
{
"Ref": "KmsKeyManager"
}
]
}
}
]

Launch an ec2 instance with cloudformation

I am trying to launch an ec2 instance using cloudformation.I created this json template but I get error Template format error: At least one Resources member must be defined.
{
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : "ami-08ddb3f251a88cf33",
"InstanceType" : "t2.micro ",
"KeyName" : "Stagingkey",
"LaunchTemplate" : {
"LaunchTemplateId" : "jen1",
"LaunchTemplateName" : "Launchinstance",
"Version":"V1"
},
"SecurityGroupIds" : [ "sg-055f49a32efd4238b" ],
"SecurityGroups" : [ "jenkins_group" ],
}
}
What am I doing wrong?
Is there any other template for ap-south-1 region which I could use? Any help would be appreciated.
The error says it all: At least one Resources member must be defined.
The major sections of a template are:
Parameters
Mappings
Resources
Outputs
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "My Stack",
"Resources": {
"MyInstance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-08ddb3f251a88cf33",
"InstanceType": "t2.micro ",
"KeyName": "Stagingkey",
"LaunchTemplate": {
"LaunchTemplateId": "jen1",
"LaunchTemplateName": "Launchinstance",
"Version": "V1"
},
"SecurityGroupIds": [
"sg-055f49a32efd4238b"
],
"SecurityGroups": [
"jenkins_group"
]
}
}
}
}
You'll need to test it. For example, it is unlikely that you will define both SecurityGroupIds and SecurityGroups.
All the properties you have entered are properties of an EC2 resource, which you need to declare. You have no resources block/a logical name for you resource, like so:
"Resources": {
"MyTomcatName": {
"Type": "AWS::EC2::Instance",
"Properties": {
[...]

Cannot use resultSelector while developing an Azure DevOps extension

I am working on a custom extension for Azure Devops which already contains a service endpoint:
"type": "ms.vss-endpoint.service-endpoint-type"
In addition, I would like to create a custom Release Artifact Source:
“type”: “ms.vss-releaseartifact.release-artifact-type”
Following this documentation, my current struggle is in filling the fields under the Artifact Source using an external API. I tried many patterns in the following ‘resultSelector’ and ‘resultTemplate’, but couldn’t hit one that worked for me.
In my example, I would like to take all the ‘uri’ values under ‘builds’ in the json response and present them in the ‘definition’ inputDescriptor of the Artifact Source. All my attempts resulted in an empty combo-box, even though I can see the request reaching the required API.
The json I would like to parse into the combo-box:
{
"builds": [
{
"uri": "/build1",
"lastStarted": "2018-11-07T13:12:42.547+0000"
},
{
"uri": "/build2",
"lastStarted": "2018-11-09T15:40:30.315+0000"
},
{
"uri": "/build3",
"lastStarted": "2018-11-12T17:46:24.805+0000"
}
],
"uri": "https://<server-address>/api/build"
}
Can you please help me create the Mustache pattern to retrieve the above "uri" values?
I tried:
$.builds[*].uri
which doesn't seem to work.
Here's some more information in case it helps.
Service endpoint's datasources:
"dataSources": [
{
"name": "TestConnection",
"endpointUrl": "{{endpoint.url}}/api/plugins",
"resourceUrl": "",
"resultSelector": "jsonpath:$.values[*]",
"headers": [],
"authenticationScheme": null
},
{
"name": "BuildNames",
"endpointUrl": "{{endpoint.url}}/api/build",
"resultSelector": "jsonpath:$.builds[*].uri"
},
{
"name": "BuildNumbers",
"endpointUrl": "{{endpoint.url}}/api/builds/{{definition}}",
"resultSelector": "jsonpath:$.buildsNumbers[*].uri"
}
]
Artifact source:
"inputDescriptors": [
{
"id": "connection",
"name": "Artifactory service",
"inputMode": "combo",
"isConfidential": false,
"hasDynamicValueInformation": true,
"validation": {
"isRequired": true,
"dataType": "string",
"maxLength": 300
}
},
{
"id": "definition",
"name": "definition",
"description": "Name of the build.",
"inputMode": "combo",
"isConfidential": false,
"dependencyInputIds": [
"connection"
],
"validation": {
"isRequired": true,
"dataType": "string",
"maxLength": 300
}
},
{
"id": "buildNumber",
"name": "Build Number",
"description": "Number of the build.",
"inputMode": "combo",
"isConfidential": false,
"dependencyInputIds": [
"connection"
],
"validation": {
"isRequired": true,
"dataType": "string",
"maxLength": 300
}
}
],
"dataSourceBindings": [
{
"target": "definition",
"dataSourceName": "BuildNames",
"resultTemplate": "{ Value : \"{{uri}}\", DisplayValue : \"{{uri}}\" }"
},
{
"target": "versions",
"dataSourceName": "BuildNumbers",
"resultTemplate": "{ Value : \"{{uri}}\", DisplayValue : \"{{uri}}\" }"
},
{
"target": "latestVersion",
"dataSourceName": "BuildNumbers",
"resultTemplate": "{ Value : \"{{uri}}\", DisplayValue : \"{{uri}}\" }"
},
{
"target": "artifactDetails",
"resultTemplate": "{ Name: \"{{version}}\", downloadUrl : \"{{endpoint.url}}\" }"
},
{
"target": "buildNumber",
"dataSourceName": "BuildNumbers",
"resultTemplate": "{ Value : \"{{uri}}\", DisplayValue : \"{{uri}}\" }"
}
]
}
Any help provided will be highly appreciated.
The working combination for this case is:
dataSources:
{
"name": "BuildNames",
"endpointUrl": "{{endpoint.url}}/api/build",
"resultSelector": "jsonpath:$.builds[*]"
}
dataSourceBindings:
{
"target": "definition",
"dataSourceName": "BuildNames",
"resultTemplate": "{ \"Value\" : \"{{{uri}}}\", \"DisplayValue\" : \"{{{uri}}}\" }"
}

Google Action / Dialogflow : how to ask for geolocation

I'm trying to implement a simple app for Google Assistant.
All works fine, but now I have a problem with the "permission" helper :
https://developers.google.com/actions/assistant/helpers#helper_intents
I have an intent connected with webhook to my java application. When an user types a sentence similar to "near to me", I want to ask to him his location and then use lat/lon to perform a search.
es: Brazilian restaurant near to me
my intent "searchRestaurant" is fired
I receive the webhook request and I parse it
if I find a parameter that is connected to a sentence like "near to me", so instead to response with a "Card" or a "List" I return a JSON that represent the helper request :
{
"conversationToken": "[]",
"expectUserResponse": true,
"expectedInputs": [
{
"inputPrompt": {
"initialPrompts": [
{
"textToSpeech": "PLACEHOLDER_FOR_PERMISSION"
}
],
"noInputPrompts": []
},
"possibileIntents": [
{
"intent": "actions.intent.PERMISSION",
"inputValueData": {
"#type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
"optContext": "Posso accedere alla tua posizione?",
"permission": [
"NAME",
"DEVICE_PRECISE_LOCATION"
]
}
}
]
}
]
}
but something seems to be wrong, and I receive an error:
"{\n \"responseMetadata\": {\n \"status\": {\n \"code\": 10,\n \"message\": \"Failed to parse Dialogflow response into AppResponse because of empty speech response\",\n \"details\": [{\n \"#type\": \"type.googleapis.com/google.protobuf.Value\",\n \"value\": \"{\\"id\\":\\"1cc45c5e-c398-4ea7-98a5-408f31ce142d\\",\\"timestamp\\":\\"2018-08-02T14:45:05.752Z\\",\\"lang\\":\\"it\\",\\"result\\":{},\\"alternateResult\\":{},\\"status\\":{\\"code\\":206,\\"errorType\\":\\"partial_content\\",\\"errorDetails\\":\\"Webhook call failed. Error: Failed to parse webhook JSON response: Cannot find field: conversationToken in message google.cloud.dialogflow.v2.WebhookResponse.\\"},\\"sessionId\\":\\"1533221100163\\"}\"\n }]\n }\n }\n}"
The "conversationToken" is filled, so I don't understand the error message.
Maybe I'm trying to perform the operation in a wrong way.
So, which is the correct way to call this helper?
--> I've created a second intent "askGeolocation" that have "actions_intent_PERMISSION" as "Event", and ... if I understand correctly the documentation, should be trigger if the request for helper is correct.
How can I get this working?
UPDATE :
I find some example of the json response for ask permission and seems that it should be different from the one above that i'm using :
https://github.com/dialogflow/fulfillment-webhook-json/blob/master/responses/v2/ActionsOnGoogle/AskForPermission.json
{
"payload": {
"google": {
"expectUserResponse": true,
"systemIntent": {
"intent": "actions.intent.PERMISSION",
"data": {
"#type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
"optContext": "To deliver your order",
"permissions": [
"NAME",
"DEVICE_PRECISE_LOCATION"
]
}
}
}
}
}
so, i've implemented it and now the response seems to be good (no more error on parsing it), but i still receive an error on it validation :
UnparseableJsonResponse
API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: "permission: Cannot find field."
so, a problem still persist.
Anyone know the cause?
Thanks
After some tests i found the problem.
I was returning a wrong json repsonse with "permission" instead of "permissions":
"permission**s**": [
"NAME",
"DEVICE_PRECISE_LOCATION"
]
So the steps to ask for location are correct. I report them here as a little tutorial in order to help who is facing on it for the first time:
1) In DialogFlow, add some logic to your Intent, in order to understand when is ok to ask to user his location. In my case, i've added a "parameter" that identify sentences like "nearby" and so on.
2) When my Intent is fired i receive to my java application a request like this :
...
"queryResult": {
"queryText": "ristorante argentino qui vicino",
"action": "bycategory",
"parameters": {
"askgeolocation": "qui vicino",
"TipoRistorante": ["ristorante", "argentino"]
},
...
3) If "askgeolocation" parameter is filled, instead to return a "simple message" o other type of message, i return a json for ask the permission to geolocation :
{
"payload": {
"google": {
"expectUserResponse": true,
"systemIntent": {
"intent": "actions.intent.PERMISSION",
"data": {
"#type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
"optContext": "To deliver your order",
"permissions": [
"NAME",
"DEVICE_PRECISE_LOCATION"
]
}
}
}
}
}
4) You MUST have a second Intent that is configured with "actions_intent_PERMISSION " event :
No training phrases
No Action and params
No Responses
But with Fulfillment active :
5) Once your response arrive to Google Assistant this is the message that appear :
6) Now, if user answer "ok" you receive this json on your webhook :
{
"responseId": "32cf46cf-80d8-xxxxxxxxxxxxxxxxxxxxx",
"queryResult": {
"queryText": "actions_intent_PERMISSION",
"action": "geoposition",
"parameters": {
},
"allRequiredParamsPresent": true,
"fulfillmentMessages": [{
"text": {
"text": [""]
}
}],
"outputContexts": [{
"name": "projects/xxxxxxxxxxxxxxxxxxxxx"
}, {
"name": "projects/xxxxxxxxxxxxxxxxxxxxx",
"parameters": {
"PERMISSION": true
}
}, {
"name": "projects/xxxxxxxxxxxxxxxxxxxxx"
}, {
"name": "projects/xxxxxxxxxxxxxxxxxxxxx"
}, {
"name": "projects/xxxxxxxxxxxxxxxxxxxxx"
}, {
"name": "projects/xxxxxxxxxxxxxxxxxxxxx"
}],
"intent": {
"name": "projects/xxxxxxxxxxxxxxxxxxxxx",
"displayName": "geoposition"
},
"intentDetectionConfidence": 1.0,
"languageCode": "it"
},
"originalDetectIntentRequest": {
"source": "google",
"version": "2",
"payload": {
"isInSandbox": true,
"surface": {
"capabilities": [{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
}, {
"name": "actions.capability.SCREEN_OUTPUT"
}, {
"name": "actions.capability.AUDIO_OUTPUT"
}, {
"name": "actions.capability.WEB_BROWSER"
}]
},
"requestType": "SIMULATOR",
"inputs": [{
"rawInputs": [{
"inputType": "KEYBOARD"
}],
"arguments": [{
"textValue": "true",
"name": "PERMISSION",
"boolValue": true
}],
"intent": "actions.intent.PERMISSION"
}],
"user": {
"lastSeen": "2018-08-03T08:55:20Z",
"permissions": ["NAME", "DEVICE_PRECISE_LOCATION"],
"profile": {
"displayName": ".... full name of the user ...",
"givenName": "... name ...",
"familyName": "... surname ..."
},
"locale": "it-IT",
"userId": "xxxxxxxxxxxxxxxxxxxxx"
},
"device": {
"location": {
"coordinates": {
"latitude": 45.xxxxxx,
"longitude": 9.xxxxxx
}
}
},
"conversation": {
"conversationId": "xxxxxxxxxxxxxxxxxxxxx",
"type": "ACTIVE",
"conversationToken": "[]"
},
"availableSurfaces": [{
"capabilities": [{
"name": "actions.capability.SCREEN_OUTPUT"
}, {
"name": "actions.capability.AUDIO_OUTPUT"
}, {
"name": "actions.capability.WEB_BROWSER"
}]
}]
}
},
"session": "projects/xxxxxxxxxxxxxxxxxxxxx"
}
that contains, name/surname and latitude/longitude. This information can be saved in your application, in order to not perform again this steps.
I hope this helps.
Davide
In your intent, you can ask for a parameter with a custom Entity. This you can do like this:
entity you can define as "near"
put all the synonyms for near for which you want to trigger location permission in this entity
do not mark this parameter as "required"
do not put any prompt
in the training phrases, add some phrases with this parameter
in your webhook, keep a check on the parameter, if present ask for permission if not continue.
add a permission event to another intent
do your post permission processing in that intent
Entity
Intent
I hope you get it.
There are samples on this topic specifically that guide you through exactly what's needed for requesting permissions in Node and Java.
Note: There are helper intents samples available in Node and Java as well.

aws cloudformation -resource property error

I have defined my parameters like this:
{
"PrivateSubnets":{
"Description":"db subnetlist",
"Type": "List<AWS::EC2::Subnet::Id>"
},
"VPCLIST": {
"Description": "VPC list",
"Type": "List<AWS::EC2::VPC::Id>"
}
}
and referring the above parameters in "resources" section like below:
"InstanceSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"VpcId" : {"Ref": "VPCLIST"} ,
"GroupDescription" : "Enable 3306/80/SSH access via port 22"
}
and while executing this I am getting the below error.
AWS::EC2::SecurityGroup InstanceSecurityGroup "Value of property VpcId must be of type String"
Note: I have only default VPC available which is not taken as string? any solutions to this issue...
The correct way is make this change:
{
"PrivateSubnets": {
"Description":"db subnetlist",
"Type": "AWS::EC2::Subnet::Id"
},
"VPCLIST": {
"Description": "VPC list",
"Type": "AWS::EC2::VPC::Id"
}
}
The Security Groups requires the VpcId to be a string, the property is an array list, So you need to change the property to Type: String, or use the
Fn::Select function.
{ "Fn::Select" : [ 0, VPCLIST ] }
List – An array of VPC IDs
{
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupName" : String,
"GroupDescription" : String,
"SecurityGroupEgress" : [ Security Group Rule, ... ],
"SecurityGroupIngress" : [ Security Group Rule, ... ],
"Tags" : [ Resource Tag, ... ],
"VpcId" : String
}
}
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html