How to change the name of the input and output file dynamically in workitem method in design automation api for Revit - autodesk-forge

I am working on a project where I need to generate output Revit file based on the input json file in the Design automation API for Revit.
Since my input json string was large, I create a json file example "InputFile.json" and upload it to the cloud and pass the signed url to it to the work item and activity as input parameter, the generated output is a zip file example "OutputFile.zip" which is again uploaded to the cloud using the signed url.
My project works properly using this process. But since the name used for the input and output files are fixed, I am facing issue when I send continuous request, I get mismatched output.
Activity request
..
"parameters": {
"Inputs": {
"zip": false,
"ondemand": false,
"verb": "get",
"description": "Element parameters",
"required": true,
"localName": "InputFile.json"
},
"Result": {
"zip": true,
"ondemand": false,
"verb": "put",
"description": "new created element",
"required": true,
"localName": "OutputFile"
}
},
...
and the WorkItem request
...
"arguments":{
"Inputs":{
"url":"https://storage.googleapis.com/XXXXXXX/InputFile.json?XXXXXXXXXXXXXXXsigned-url"
},
"Result":{
"verb":"put",
"url":"https://storage.googleapis.com/XXXXXXX/OutputFile.zip?XXXXXXXXXXXXXXXsigned-url",
...
How can I pass dynamically generated names like "InputFile_[DATE].json" and "OutputFile_[DATE].zip"?
Thanks in advance
Regards

You should be able to replace the localName value when submitting the workitem by adding the "localName" attribute to your argument.
Example:
"arguments":{
"Inputs":{
"url":"https://storage.googleapis.com/XXXXXXX/InputFile.json?XXXXXXXXXXXXXXXsigned-url"
},
"Result":{
"verb":"put",
"url":"https://storage.googleapis.com/XXXXXXX/OutputFile.zip?XXXXXXXXXXXXXXXsigned-url",
"localName": "myOutputFileName"
}
}

Related

How to define the output filename based on input rvtFile in Activity?

I've created activity , and my output file name is always result.zip.
I put my result into the bucket. When i post few workitems, everytime rezult.zip file overrides.
Is it possible to define the output file name based in inputFileName like var $rvtFile?
I've tried in my appbundle to create folder for saving results based on Document Title without extension, but i can't get those file with activity.
"parameters": {
"rvtFile": {
"verb": "get",
"description": "Input Revit model",
"required": true,
"localName": "$(rvtFile)"
},
"resultifc": {
"zip": true,
"verb": "put",
"description": "Output Ifc model",
"required": true,
"localName": "result"
}
}
I'd like to have something like :
localName :$"(rvtFile)_result"
While the result file you save in your addin code needs to be hardcoded (result.zip), note that you may always create a custom output signed URL with appropriate file location. For example:
workitem 1:
"resultifc": {
"url": https://myhostname/filename.zip
}
workitem 2:
"resultifc": {
"url": https://myhostname/othername.zip
}
Currently we do not support variable expansion of the kind:
localName :$"(rvtFile)_result"
But here is something else that you might consider using:
https://forge.autodesk.com/en/docs/design-automation/v3/developers_guide/field-guide/#variable-expansion
You can dynamically insert the work item id in your output file url.

postman duplicate collection / export + re-import

relatively new to Postman, having problem with the following simple scenario - I have a collection of Postman requests that all point to a local IP where I am developing my application. Let's suppose I finished my local development, deployed the application on some other server, and want to repeat the requests I previously created on THAT server. I know that probably one way to do this would be to use variables.
Instead of that, though, I did an export of the collection, and did a manual edit of the exported JSON file, replacing all the old local IP's with the new server IP. Also changed the collection name, and ID to something arbitrary. While the import back to Postman works, and I see the requests, they all have the old IP still hanging there, as if my replace didn't work, or as if Postman somehow caches the requests and thinks that that new collection is the same as the old one. I also tried "Duplicating" a collection and exporting the duplicated one / replacing / importing again - but the behavior seems to be the same.
Did I miss something, or should I approach what I want to do differently?
Thank you.
duh, I am dumb enough to have been substituting the "raw" URL, while right below there were the old values for "host" and "port" that are the ones Postman constructs URL from:
{
"info": {
"_postman_id": "1499274a-07bc-4ed2-87d4-b10d0cef8f8f",
"name": "some-collection-DEVSERVER",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "login (success - bad locale)",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"username\" : \"TEST\",\n\t\"password\" : \"123456\",\n\t\"locale\" : \"asd\"\n}"
},
"url": {
"raw": "http://SERVER-IP:SERVER-PORT/new-path/login",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8081",
"path": [
"old-path",
"login"
]
}
},
"response": []
},
...
]
}
So, after suggestion to use variables I ended up creating two Collection variables "base-URL-LOCAL" and "base-URL-SERVER", that play the role of constants, and a third variable "base-url" which e.g. could have the value of {{base-URL-LOCAL}} (both initial and current values have to be updated). In my exported JSON collection, i substituted all "url" elements with something like the following:
"url": {
"raw": "{{base-url}}/login",
"host": [
"{{base-url}}"
],
"path": [
"login"
]
}
That way somebody who gets my collection won't have to have pre-defined environments set up, and will have to edit collection variables, setting e.g. base-url to {{base-URL-SERVER}}

Is there any data returned from the Forge Data Management Search api to indicate a model is deleted?

When using GET projects/:project_id/folders/:folder_id/search, Forge Data Management API on a model with a deleted last version, is there a any information in the "attributes" or other returned data that indicates the file is deleted?
Currently, a second call to GET projects/:project_id/items/:item_id/versions is used to determine if the latest version is deleted (below) but it would be preferable to not call another request to get this information.
Returned JSON from /versions (with some data removed):
"data": [{
"type": "versions",
"id": "urn:adsk.wipprod:fs.file:vf.w0cwXPUwQziKIHtKBtYRaA?version=3",
"attributes": {
"versionNumber": 3,
"extension": {
"type": "versions:autodesk.core:Deleted",
"version": "1.0",
"schema": {
"href": "https://developer.api.autodesk.com/schema/v1/versions/versions:autodesk.core:Deleted-1.0"
},
"data": {
"originalName": "**.rvt"
}
}
}]
The json attribute.hidden = true seems to indicate deleted. This can be accessed via the filter[hidden] = true. I'm closing this as the correct answer.

How to convert Json (from JIRA's webhook) to Custom Java object

I have some Java REST APIs which will be invoked via JIRA Webhook configuration.
Now, when JIRA webhook is invoking REST API, there are large no. of custom fields (like customfield_17270) which contain useful data.
For example, I have configured "Create Issue" event in JIRA webhook i.e. whenever any issue will be created in JIRA, my REST API will be invoked. While creating issue in JIRA, for example, there is a field named "Issue Title" whose value is "XXX". In JSON payload, ideally key-value pair should be "Issue Title":"XXX" but it is like "Custom_Field109":"XXX".
Now the problem is how to map this dynamic JSON to Java Object.
Is there anyone who has faced similar problem.
Each time you receive the webhook, you'll need to map each custom id (e.g. customfield_10070) to it's name by querying the field JIRA REST API at GET: /rest/api/2/field
...which will give you something like this:
[
{
"id": "issuetype",
"name": "Issue Type",
"custom": false,
"orderable": true,
"navigable": true,
"searchable": true,
"clauseNames": [
"issuetype",
"type"
],
"schema": {
"type": "issuetype",
"system": "issuetype"
}
},
{
"id": "customfield_10070",
"name": "FAQ Necessary?",
"custom": true,
"orderable": true,
"navigable": true,
"searchable": true,
"clauseNames": [
"cf[10070]",
"FAQ Necessary?"
],
"schema": {
"type": "string",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons",
"customId": 10070
}
},
...
]
You should then easily be able to iterate over the fields from the webhook JSON and map the custom field id to its display name.
I was able to discuss this issue with JIRA internal team and they provided me custom fields mapping to their JIRA display name.
Basically, when we receive Json keys like Custom_field109 then it means 109 is internal database id for this attribute.
Now, based on given mapping, I parsed JSON to get required keys and then through Jackson library, I was able to map JSOn to Java.

Parse Dynamic Property name in Azure Logic App

I have been playing around with Azure Logic Apps and trying to retrieve a Pocket (ReadItLater) article so that I can create a new task in my preferred Task Manager. I have Two HTTP Connectors (one for Retrieve Operation using Pocket API and another post data to Todoist (my preferred task manager).
I can retrieve the Article and the response looks like (removed a few properties below for easy reading):
{
"statusCode": 200,
"headers": {
"pragma": "no-cache",
"status": "200 OK"
},
"body": {
"status": 1,
"complete": 1,
"list": {
"586327616": {
"item_id": "586327616",
"resolved_id": "586327616",
"given_url": "http://kenwheeler.github.io/slick/?utm_source=hackernewsletter&utm_medium=email&utm_term=design&mc_cid=58c9499fa2&mc_eid=3aaf6c4e47",
"given_title": "slick - the last carousel you'll ever need",
"time_added": "1396652224",
"time_updated": "1405156517",
"resolved_title": "slick",
"resolved_url": "http://kenwheeler.github.io/slick/?utm_source=hackernewsletter&utm_medium=email&utm_term=design&mc_cid=58c9499fa2&mc_eid=3aaf6c4e47",
"excerpt": "Add slick.js before your closing <body> tag, after jQuery (requires jQuery 1.7 +) <script type=\"text/javascript\" src=\"slick/slick.min.",
"word_count": "22"
}
}
}
}
Now I want to parse the above response to retrieve individual article properties (i.e. resolved_title). The issue here is the object under the list "586327616" is dynamic and changes for every article, and I can't seem to parse this as an expression in Logic App. My current action in Logic App looks like:
"postToTodoist": {
"conditions": [
{
"expression": "#equals(outputs('getPocketArticles')['statusCode'], 200)"
},
{
"dependsOn": "getPocketArticles"
}
],
"inputs": {
"body": "#{outputs('getPocketArticles')['body']['list'][0]['resolved_title']}",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"method": "POST",
"repeat": {},
"uri": "https://todoist.com/API/v6/add_item"
},
"type": "Http"
}
For the expression I have tried converting the response to string, using coalesce and trying to access using an index, but nothing seem to work. In the error, it tells me what that the available property is i.e.:
{"code":"InvalidTemplate","message":"Unable to process template language expressions in action 'postToTodoist' inputs at line '1' and column '11': 'The template language expression 'coalesce(body('getPocketArticles')['list']).resolved_title' cannot be evaluated because property 'resolved_title' doesn't exist, available properties are '586327616'. Please see https://aka.ms/logicexpressions for usage details.'."}
I feel that it is not possible to construct an expression without knowing the name of the property, has anyone done something similar?