Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question