0

I'am trying to download the Forge viewables in a C# application, but I'm having trouble downloading the svf file. The following code returns "The requested resource does not exist." If I run the same urn in the node.js extractor example it works fine. I'm not that familiar with using REST api's in C# and is probably missing a header or parameter. I have tried lots of combinations without success. Hopefully someone can point me in the right direction.

var urn = "urn:adsk.viewing:fs.file:<xxxxxURNxxxxxx>/output/0/0.svf";
var client = new RestClient("https://developer.api.autodesk.com");
var request = RestRequest("/derivativeservice/v2/derivatives/{" + urn + "}", Method.GET);
request.AddParameter("Authorization",string.Format("Bearer " + Configuration.Default.AccessToken),ParameterType.HttpHeader);
var result = client.Execute(request);
FrodeTo
  • 83
  • 1
  • 10
  • There is nothing special about calling REST APIs. REST calls are just HTTP calls. If you get a 404 it means you used the wrong URL. Curly braces aren't valid URL characters. Did you post some string with placeholder but forgot to actually remove the placeholders? – Panagiotis Kanavos May 26 '17 at 14:20
  • Did you try to paste a ULR that uses string interpolation? You should have used `$"/derivativeservice/v2/derivatives/{urn}"` in this case – Panagiotis Kanavos May 26 '17 at 14:23

1 Answers1

0

I think you just need to remove the curly braces from the URL, so use RestRequest("/derivativeservice/v2/derivatives/" + urn, Method.GET);

Adam Nagy
  • 1,700
  • 1
  • 9
  • 14
  • Or use String.Format, or use interpolation with `$"/derivativeservice/v2/derivatives/{urn}"` – Panagiotis Kanavos May 26 '17 at 14:22
  • Thank you for the suggestions. I have tried lots of format combinations, including the ones mentioned above, but without success. What is strange is that using node.js I am able to download this file with the exact same urn. And in my C# project I am able to download the manifest using curly bracets like this: `RestRequest("/derivativeservice/v2/manifest/{"+urn64+"}",Method.GET);` – FrodeTo May 30 '17 at 06:52
  • Maybe you could use a tool like http://www.telerik.com/fiddler to see what exactly is being sent (data, headers, URL) in case of the C# code vs the Node.js code. There must be a difference if one is working but not the other. – Adam Nagy Jun 01 '17 at 13:07
  • Thanks Adam. Fiddler helped me find out how to fix this. I had to run HttpUtility.UrlEncode on the urn before calling the Restrequest. – FrodeTo Jun 08 '17 at 12:47