Recovering files after processing - autodesk-forge

Before the October eve, the information provided in the Revit console log allowed us to recover the return files.
Now this is not possible anymore!
Before:
"outputFile": {
"optional": true,
"localName": "OutputRvtFile.rvt",
"url": "https://developer.api.autodesk.com/oss/v2/buckets/caqg5kf4prwtqmmvrw_designautomation/objects/20190718115854_output_xxxxxxx.rvt",
"headers": {
"Authorization": "Bearer eyJh…."
},
"verb": "put"
},
Now :
"outputFile": {
"optional": true,
"localName": "OutputRvtFile.rvt",
"url": "https://developer.api.autodesk.com/Masked:tAUm....1RT08=",
"headers": {
"Authorization": "Masked:MT….E+zJONm3VU="
},
"verb": "put"
},
Before we had the file link as well as the varible Bearer but now there is more and the documentation has not been updated, or not found the latest news.
When I donwload the file, I have this element :
{ "developerMessage":"The requested resource does not exist.","userMessage":"","errorCode":"ERR-002","more info":"http://developer.api.autodesk.com/documentation/v1/errors/err-002"}
Could someone put me on the right road?
What is my problem?

Olivier,
The RVT output file's URL and authorization headers are the same URL and authorization headers you passed into Design Automation for Revit as part of your WorkItem payload.
Autodesk values your privacy and the security of your data in Design Automation. Your URLs and bearer tokens are being masked in Design Automation logs, including report.log, so that your sensitive data is not visible to Autodesk after your job is run.
Best,
Michael

Related

How to import dxf into a dwg using Autodesk Forge

I have implemented a viewer using Autodesk Platform Services (former name Forge) on .NET Core. In the bucket I upload 2D drawings in .dwg format.
I enabled the markup feature in the viewer, so now I can make any markup on top of the .dwg
What I have for the moment looks like this:
I need to save this dwg with the markups I did, and either have it as a 2nd dwg inside the bucket or to override the original one.
The steps I have taken until now:
In javascript behind I can get the markups only as .svg format using the .generateData() on the MarkupsCore extension:
const markupCore = await viewer.loadExtension('Autodesk.Viewing.MarkupsCore');
let svgMarkup = markupCore.generateData();
After getting the svg mark up, I convert it in .dxf file.
I think I need to use the Design Automation API to import this dxf file into the dwg,
but I don't know how to handle this.
I have checked the following link on importing dxf into dwg but so far I can't find something for my case.
AutoDesk Design Automation tutorials on autocad
In case someone knows maybe another way on handling this, please let me know.
I think I need to use the Design Automation API to import this dxf file into the dwg, but I don't know how to handle this.
Yes that is correct, you may insert the dxf into the main drawing, you should be knowing scaling and position, so that will placed correctly on top your drawing.
Activity
{
"id": "{{ _.activityId }}",
"commandLine": [
"$(engine.path)\\accoreconsole.exe /i \"$(args[main].path)\" /s $(settings[script].path)"
],
"parameters": {
"main": {
"verb": "get",
"description": "test",
"required": true,
"localName": "$(inputFile)"
},
"overlay": {
"verb": "get",
"description": "",
"required": true,
"localName": "markups.dxf"
},
"result": {
"verb": "put",
"description": "",
"required": true,
"localName": "result.dwg"
}
},
"engine": "Autodesk.AutoCAD+24_1",
"description": "import markups",
"settings": {
"script": "-insert\nmarkups.dxf\n4,1,0\n1\n1\n0\nsaveas\n2018\nresult.dwg\n"
}
}
WorkiItem
{
"activityId": "{{ _.nickName }}.{{ _.activityId }}+{{ _.alias }}",
"arguments": {
"main": {
"url": "urn:adsk.objects:os.object:madlybuckets/main.dwg",
"verb": "get",
"headers": {
"Authorization": "Bearer {{ _.oAuthToken }}"
}
},
"overlay": {
"url": "urn:adsk.objects:os.object:madlybuckets/markups.dxf",
"verb": "get",
"headers": {
"Authorization": "Bearer {{ _.oAuthToken }}"
}
},
"result": {
"verb": "put",
"url": "urn:adsk.objects:os.object:madlybuckets/result.dwg",
"headers": {
"Authorization": "Bearer {{ _.oAuthToken }}"
}
}
}
}
Here the main.dwg, markups.dxf is uploaded to APS Object Storage Service so that I can directly use object id of uploaded files instead of passing the object URL to the workitem.

Download Files from BIM 360 Without Authorization

I am integrating between Design automation and BIM 360 API in autodesk forge
I call step 7 Design automation
https://forge.autodesk.com/en/docs/design-automation/v3/tutorials/revit/step7-post-workitem/
{
"activityId": "YOUR_NICKNAME.DeleteWallsActivity+test",
"arguments": {
"rvtFile": {
"url": "SIGNED_URL_TO_INPUT_FILE",
"pathInZip": "PATH_TO_RVT_FILE_WITHIN_ZIP_FILE"
},
"result": {
"verb": "put",
"url": "SIGNED_URL_TO_RESULT"
}
}
}'
The param rvtFile.(url), i binding link download file by step 5 in Bim 360 Document
https://forge.autodesk.com/en/docs/bim360/v1/tutorials/document-management/download-document/
{
"activityId": "cbbdemo.DemoTestingActivity43+test",
"arguments": {
"rvtFile": {
"url": "https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/11d42fe8-7612-4120-ad7d-a688e49143a1.rvt",
"localName": "testing.rvt",
},
"params": {
"url": "data:application/json,{'action' : 'generate','scaffoldName' : 'SM0918', 'space' : 300,'isGenFront' : true,'data' : ['138763','138533']}"
},
"result": {
"verb": "put",
"url": "https://developer.api.autodesk.com/oss/v2/signedresources/fbe64c4f-1073-49a7-810b-95658e51b361?region=US"
}
}
}
But when download file revit by API Bim 360 is failed because need token Authorization
So is there a way to download files from bim 360 without tokens?
Unfortunately, you cannot call the OSS API https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/11d42fe8-7612-4120-ad7d-a688e49143a1.rvt without passing an access token.
The solution is to use a Signed URL to download the file, but since you're not the owner of the bucket wip.dm.prod. It's owned by BIM360 or ACC service itself. So you cannot create Signed URLs for objects stored on the wip.dm.prod bucket. So, at this moment, please pass a valid access token like the one below:
{
"activityId": "cbbdemo.DemoTestingActivity43+test",
"arguments": {
"rvtFile": {
"url": "https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/11d42fe8-7612-4120-ad7d-a688e49143a1.rvt",
"localName": "testing.rvt",
"headers": {
"Authorization": "Bearer {{Bearer}}",
"Content-Type": "application/octet-stream"
}
},
"params": {
"url": "data:application/json,{'action' : 'generate','scaffoldName' : 'SM0918', 'space' : 300,'isGenFront' : true,'data' : ['138763','138533']}"
},
"result": {
"verb": "put",
"url": "https://developer.api.autodesk.com/oss/v2/signedresources/fbe64c4f-1073-49a7-810b-95658e51b361?region=US"
}
}
}

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

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"
}
}

Actionable Messages with HTTP Post in Outlook and new SPFx WebPart

I have created an Actionable Message and registered a provider in Office365, which is approved for my organization. I'm sending the message via Microsoft Flow.
The message contains HttpPost actions in which I want to receive the response with am HTTP triggered Flow.
This is the JSON of the actionable message (I've removed the FLOW urls, and #'s are escaped.):
{
"##type": "MessageCard",
"##context": "http://schema.org/extensions",
"originator": "<my_provider_id>",
"summary": "Klanttevredenheidsonderzoek ",
"title": "Bent u tevreden over de afhandeling van **melding 92138749247**",
"text": "Graag horen we of u tevreden bent over deze melding",
"themeColor": "E81123",
"sections": [
{
"potentialAction": [
{
"##type": "HttpPOST",
"name": "Slecht!",
"headers": [{ "Content-Type": "application/json" }],
"target": "<flowurl>?<>flowurlparameters",
"body": "Slecht!"
},
{
"##type": "HttpPOST",
"name": "Goed!",
"headers": [{ "Content-Type": "application/json" }],
"target": "<flowurl>?<>flowurlparameters",
"body": "Goed"
}
]
},
{
"startGroup": true,
"title": "**Disclaimer**",
"text": ". 2018"
}
]
}
I have two problems:
If I mail my own O365 account, I get the mail with the message
showing correctly. However, the post buttons do not work correctly,
and the link I see when I hover over the buttons is missing the URL
parameters (which might be the cause it's not working). What could I
be doing wrong, or is it still too early for this to work? How can I
debug this?
In the new SPFx O365Connectors webpart the HTTPPost actions are missing completely. The rest of the message is shown correctly. Are HTTPPost actions not supported yet? Or will they not be supported at all? Or is something wrong with what I'm doing..?
Microsoft has now added support for the scenario of catching HTTP Post operations from within an actionable email by Microsoft Flow. The key is to explicitly set the authorization header to an empty string.
Below snippet uses the adaptive card schema v1.0 at http://adaptivecards.io/schemas/adaptive-card.json
"actions": [
{
"type": "Action.Http",
"title": "Light",
"method": "POST",
"headers": [
{
"name": "Authorization",
"value": ""
}
],
"url": "<a http triggered Flow URL>",
"body": "{'currentRoom':'room1','currentState':'roomState1','action':null,'exit':null,'object':null,'objectAction':null,'userEmail':'someuser#somedomain.com'}"
}
]
I received the following response from a Microsoft employee regarding this issue:
The reason it fails is because the logic app doesn’t allow sending
Authorization header and it responds back 401 Unauthorized. We send
Authorization header to identify that the request is from Office 365.
The logic app works fine without Authorization header.
I will discuss this with the team and see if we can resolve this kind
of scenario, and will update you on the status.
So for now it seems this scenario is not supported.

api access token post request, where to start

I've been struggling learning Auth for several months now, it comes down to I don't know where to start, it seems there are a bunch of different methods.
I am using an API that provides a token called "Personal Access Token".
Does this mean it's a Bearer or Web Token? I'm lost with this terminology.
They allow you to play with their API in their online tools. I am making a POST request.
The api provides this info:
Link to send Post Request: www.hackerrank.com/restoflink
Request Headers:
{
"Content-Type": "application/json",
"Accept": "application/json",
"Content-Length": 190
}
Request Body:
{
"username": "testing",
"subject": "test",
"message": "test",
"send_email": "true",
"force": "false",
"hide_login_credentials": "true",
"access_token": "Access Token Number"
}
Here is my code:
function onFormSubmission(e){
var accessToken ="ACCESS_TOKEN";
var options = {
method: "post",
headers: {
"Accept": "application/json",
"Authorization": "Bearer " + accessToken
},
payload: {
"username": "testing#gmail.com",
"subject": "test",
"message": "test",
"send_email": "true",
"force": "false",
"hide_login_credentials": "true",
"access_token": "ACCESS TOKEN",
"muteHttpExceptions": "false",
"contentType": "application/json"
}
}
var response = UrlFetchApp.fetch("linkhere", options);
Logger.log(response.getResponseCode())
Logger.log(response.getContentText());
}
When I run this code without the bearer token in the header, I get a "404 truncated server error, "Invalid Access Token"".
This is why I include the token in the in header ("I'm guessing it is a Bearer Token)
The response I get from the request is 200 but it doesn't perform the action I expect it to.
I'm confused on what adjustment I have to make, even though I'm getting at 200 response code, something isn't working with my request from Apps Script.
I tried making the request from POSTMAN and the api's test tools and all my attempts worked, which makes me believe I am doing something wrong in my script.
Any help would be greatly appreciated, this post already helped out a lot!
Here was my error:
UrlFetchApp.fetch("www.hackerrank.com/x/api/v2/tests?duration=-1&access_token=123", options)
URL: ""
I had to add 'https://', for a while I used 'http' and that didn't work.
They call it a permanent OAuth token in their documentation (linked from your comments), but the way they use it is very simple and not like the OAuth implementations I've worked with in the past.
You don't need to include the access token in your headers, simply append &access_token=[your token] to the URL ("linkhere") of your request.
Example:
UrlFetchApp.fetch("www.hackerrank.com/x/api/v2/tests?duration=-1&access_token=123", options)