Closed violacambie closed 7 years ago
Hey @violacambie , thanks for writing this up!
As a first few suggestions :
WebRequest.AddFile
node ? It was designed for this and should be able to handle uploading the file for you.POST
request, most web services accept creation of new records using that method.Also, could you let us know which service you're using, might help troubleshooting if we're able to look at their documentation and the DYN file. I assume you're trying to upload to a bucket on either AWS S3 or Azure (blob storage) ?
Thanks for the replay!
yes I have tried the "WebRequest.AddFile" but I'm not sure the string should I use for a Revit model as "contentType": application/rvt? .rvt? application/octet-stream? binary?
Please have a look at the screenshot. With Postman I can simply upload a file as binary
I'm uploading the models in a bucket on the Autodesk Platforme ( Forge ) and I'm not sure wich type of storage is.
Hey Viola @violacambie ,
First off, thanks a lot for posting the Postman
screenshot, helped a lot to know what works there and saved quite a few steps!
I signed up to a trial for Forge to test this out, was really curious how to get it working, here's what I found :
Content-Type
has to be application/octet-stream
AddFile
node was failing because it's defaulting to uploading in a multi-part/form way. this is equivalent to switching Postman
body to form-data
instead of binary
multi-part
data.So, I added another node to the package called WebRequest.AddFileAsBytes
which adds the file as raw bytes to the request body.
I'm releasing the updated, beta version of this on the Dynamo package manager tonight, search for DynaWeb
, it will include this new node.
I've uploaded the entire DYN workflow in the samples folder, have a look at sample 7.
Please try it all out and let me know how you get on 🤓
Hey Radu@radumg
thanks for the updated version. The WebRequest.AddFileAsBytes works good!
However the WebRequest.SetMethod looks like is not working properly
I have solved this issues thanks your new Execute.PUT !
Plus the Content-Type works both with "application/octet-stream" and "application/x-www-form-urlencoded": should I prefer just one of those?
Thanks for the feedback!
I had the same issue as your first screenshot - SetMethod
is working, but the Request object is not being updated due to some Dynamo caching, which means it's still using the old token/request etc.
Disconnecting the nodes, closing the file and re-opening should do the trick - i'm looking into ways of forcing it to update each time.
Re: the Content-Type
, if both work, then the Forge
platform isn't enforcing/using that, so it should also work without :grin:
Expected Behavior
I would want to upload a .rvt file on a bucket hosted online.
Actual Behavior
I'm using PUT method. I can add Headers and Parameters to the URL but I'm not sure how upload the Revit file.
Steps to Reproduce the Problem
The WebRequest.AddBody doesn't let me specify the type ( "binary") of the model: any suggestion?
Specifications