R
R
run1822020-01-23 19:48:08
C++ / C#
run182, 2020-01-23 19:48:08

How to run cURL command from Azure WebAPI?

The project is in Azure. The code below returns the error "EXCEPTION: The system cannot find the file specified".
How can I make the correct call, is there a curl file somewhere on the server in Azure, or can I somehow install it there? Or how else can I run the following command

curl -v -k --key keyfile.key --cert certfile.crt:'passphrase' https://server1.com/sms
?
try
            {
                using (Process pProcess = new Process())
                {
                    pProcess.StartInfo.FileName = @ExtCurl;
                    pProcess.StartInfo.Arguments = ArgumentFull;
                    pProcess.StartInfo.UseShellExecute = false;
                    pProcess.StartInfo.RedirectStandardOutput = true;
                    pProcess.StartInfo.RedirectStandardError = true;
                    pProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    pProcess.StartInfo.CreateNoWindow = true;
                    pProcess.Start();

                    string output = pProcess.StandardOutput.ReadToEnd();
                    string error = pProcess.StandardError.ReadToEnd();

                    pProcess.WaitForExit();

                    if (error.Length > 0)
                        return "ERROR: " + error;
                    else
                        return output;
                }
            }
            catch (Exception e)
            {
                return "EXCEPTION: " + e.Message;
            }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2020-01-24
@yarosroman

You can download the file using c#. For example https://stackoverflow.com/questions/39307684/webcl... And that's it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question