Jump to content

Using Digest Authentication with the Ultimaker Api in c#


VarrickFrost

Recommended Posts

Posted · Using Digest Authentication with the Ultimaker Api in c#

Hi!

 

I am currently trying to control my Ultimaker S5 via the Api. "Get" Requests are no problem in my c# skript, however any requests that require a authentication are impossible. In Python it is quite simple, you can just use a library that does the digest authentication for you, however I spent almost a week now looking through the internet trying to get this to work in c#. Has enyone an Idea on how to approch this or has expiriance with that? Any hints would be much appreciated!

 

All best,

 

Varrick

  • Link to post
    Share on other sites

    • 1 year later...
    Posted · Using Digest Authentication with the Ultimaker Api in c#

    Hi,
    I am working on making a website where users upload theri gcode and then print from an avalible ultimker 3, with this code i managed to get the printer to work:
     

                            var url = "http://YOUR IP/api/v1/print_job";
                            var apiKey = "YOUR API KEY";
                            var apiSecret = "YOUR API SECRET";
                            var jobName = fileResponse.FileName;
                            var filePath = fileResponse.FullFilePath; //full file path to the file

                            using var handler = new HttpClientHandler
                            {
                                Credentials = new NetworkCredential(apiKey, apiSecret)
                            };

                            using var client = new HttpClient(handler);

                            using var fileStream = new FileStream(filePath, FileMode.Open);
                            using var content = new MultipartFormDataContent();
                            using var fileContent = new StreamContent(fileStream);

                            fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/octet-stream");
                            content.Add(fileContent, "file", jobName);

                            var response = await client.PostAsync(url, content);

                            if (response.IsSuccessStatusCode)
                            {
                                var responseContent = await response.Content.ReadAsStringAsync();
                                Console.WriteLine(responseContent);
                            }

    I know that the post is old but I hope if anyone ever tries this again then it can come in handy.

    • Like 1
    Link to post
    Share on other sites

    Posted · Using Digest Authentication with the Ultimaker Api in c#

    Today I was thinking of doing something similar - I have some nest thermostats and I learned there is an API so I could make a web page that lets you see all the thermostats in all your homes all on the same screen and adjust them all from one screen and then I could have an ipad on the wall permanently...

     

    Just a thought.

    • Like 1
    Link to post
    Share on other sites

    Posted · Using Digest Authentication with the Ultimaker Api in c#
    On 3/15/2023 at 5:28 PM, gr5 said:

    Today I was thinking of doing something similar - I have some nest thermostats and I learned there is an API so I could make a web page that lets you see all the thermostats in all your homes all on the same screen and adjust them all from one screen and then I could have an ipad on the wall permanently...

     

    Just a thought.

    That is a good idea 😄

    If the API is similar to what Ultimaker has to offer then it should be relatively easy 😄

    What languages do you code in?

  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • UltiMaker Cura 5.7 stable released
        Cura 5.7 is here and it brings a handy new workflow improvement when using Thingiverse and Cura together, as well as additional capabilities for Method series printers, and a powerful way of sharing print settings using new printer-agnostic project files! Read on to find out about all of these improvements and more. 
         
          • Like
        • 18 replies
      • S-Line Firmware 8.3.0 was released Nov. 20th on the "Latest" firmware branch.
        (Sorry, was out of office when this released)

        This update is for...
        All UltiMaker S series  
        New features
         
        Temperature status. During print preparation, the temperatures of the print cores and build plate will be shown on the display. This gives a better indication of the progress and remaining wait time. Save log files in paused state. It is now possible to save the printer's log files to USB if the currently active print job is paused. Previously, the Dump logs to USB option was only enabled if the printer was in idle state. Confirm print removal via Digital Factory. If the printer is connected to the Digital Factory, it is now possible to confirm the removal of a previous print job via the Digital Factory interface. This is useful in situations where the build plate is clear, but the operator forgot to select Confirm removal on the printer’s display. Visit this page for more information about this feature.
          • Like
        • 0 replies
    ×
    ×
    • Create New...