I have python script that I can execute with no issues and get back my 200 code. I am having trouble validating that my C# code is sending the Id_Textbox.Text to the script, and getting the return code back to my label.
C#
string cmd = "C:/Python27/python.exe";
string args = String.Format(@"D:\Python Scripts\device#_put.py " + Id_TextBox.Text);
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = "C:/Python27/python.exe";
start.Arguments = string.Format("{0} {1}", cmd, args);
start.UseShellExecute = false;
start.RedirectStandardOutput = true;
using (Process process = Process.Start(start))
{
using (StreamReader reader = process.StandardOutput)
{
string myString = reader.ReadToEnd();//Blank
myString_Label.Text = myString;
}
process.WaitForExit();
}
And my tiny python script.
import httplib
Id = ''#want to pass in Id_TextBox.Text
headers = {'Content-Type': 'application/json', 'Accept': 'application/json',
'Authorization': 'apikey=#####'}
conn = httplib.HTTPSConnection('server1.net')
conn.request('POST', '/api/v1/device/' + Id, headers=headers)#Pass variable
here.
resp = conn.getresponse()
print resp.status
Any help is appreciated!