Getting link command to work c#

Everything was going well got the fileupload working fine, but can't get link command to work using same method, either throws bad request exception or empty json results string "[]"
no errors or anything, same url works fine in the website­e4f9d83ae47

7replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • even using the c# "sdk" doesn't work, getting bad request when passing in "path=blah"

    Reply Like
  • nevermind, works now. really doesn't like "-" in path name

    Reply Like
  • Glad you got it solved. Let me know if there is anything I can update in documentation or error responses to help other developers.

    Reply Like
  • Well, I'd be inclined to regard it as a bug since the mkdir command allows you to make directories with dashes in them but the link command can't retrieve them. They should all allow it or none.


    Although more info in the error returned is never a be thing. Instead of "bad request" how about "illegal characters in x parameter" or "missing required parameter x"

    Reply Like
  • I am not able to get the link command working in C#. I have gotten it to work a few times, but there is no reason I can see why it works once and then not again. I would estimate I got it to work about 3 out of 100 tries. I have used all kinds of filenames. Reading this post made me think it was underscores I had in my folder names, but I shortened them to 6 characters and tested again with no luck.

    I can create links fine when using the UI, but the C# api seems like it doesn't work. I just get generic exceptions.

    Reply Like
  • Walter Hogan  I am able to create links with the following code.

    using System;
    using System.IO;
    using System.Web;
    using System.Net;
    using System.Collections;
    using SmartFile;
    namespace SmartFileTest
        class MainClass
            public static int Main(string[] args)
                // Setup new SmartFile client
                BasicClient api = new BasicClient("xxxxxxxxxx", "xxxxxxxxxxxx");
                // Data to send in POST request
                Hashtable p = new Hashtable();
                p.Add("path", "/Public/mvp.jpg");
                p.Add("list", true);
                p.Add("read", true);
                p.Add("name", "Screenshot");
                // Create a link via POST request
                HttpWebResponse r = api.Post("/link", null, p);
                // Display output on the console
                using (var streamReader = new StreamReader(r.GetResponseStream()))
                    var responseText = streamReader.ReadToEnd();
                return 0;

    Let me know if this helps

    Reply Like
  • @Travis Cunningham Thank you for your reply. That is very similar to the code I am using and the code works, but what I found is that if I upload files prior to creating a link, the operation will time out.

    The program I am writing creates a bunch of files on the user's local PC. I am trying to modify the program to create a new folder, then upload those files to the SmartFile site and generate a link to the folder I just uploaded files to.

    What I had to do in order for this to work was change the order I did it in. First I create the folder, then create a link to that folder and then upload files. Is there a certain period of time after uploading files when the create link function will not work, presumably due to indexing the content or something of that nature?

    I have this working for my needs now, but it would be nice to know for future reference. Thanks again for your help.

    Reply Like
Like Follow
  • 3 yrs agoLast active
  • 7Replies
  • 950Views
  • 5 Following