C# 開發傳輸API URL回傳(401) 未經授權
Completed於C#中開發透過HttpWebRequest發送API URL
http://192.168.0.18:7001/ec2/bookmarks/add?guid=b648c1cf-0d5f-4f7f-8151-b36c1a7ae9a9&cameraId=8a42747b-24c0-bcf5-e0cb-7ed6c083358e&name=人員:paul-Paul&description=單號&startTimeMs=1652432804000&durationMs=60000&tag=單號:OR220413000001
或是用創建事件
都會收到(401) 未經授權的錯誤
是否有遺漏的部分,再請協助幫忙
謝謝。
string targetUrl = "http://192.168.0.18:7001/ec2/bookmarks/add?guid=" + myuuidAsString
+ "&cameraId=" + dtcam.Rows[0]["CameraId"].ToString().Trim()
+ "&name=人員:" + sysinfo.usrid + "-" + dtUsr.Rows[0]["susnm"].ToString().Trim()
+ "&description=單號"
+ "&startTimeMs=" + epoch
+ "&durationMs=60000&tag=單號:" + sShtno + "-配編:" + sDelno + "-產品:" + sPrtno + "-加總數量:" + sQty
;
OR
targetUrl = "http://192.168.0.18:7001/api/createEvent?timestamp=" + epoch
+ "&caption=單號" + sShtno + "-人員:" + sysinfo.usrid + "-" + dtUsr.Rows[0]["susnm"].ToString().Trim()
+"-配編:" + sDelno + "-產品:" + sPrtno + "-加總數量:" + sQty
//+ "&metadata={"+"cameraRefs"+":[" + dtcam.Rows[0]["CameraId"].ToString().Trim()+"]}"
;
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(targetUrl);
req.KeepAlive = true; //是否保持連線
req.Method = "GET";
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate);
using (WebResponse wr = req.GetResponse())
{
StreamReader sr = new StreamReader(wr.GetResponseStream());
result = sr.ReadToEnd();
sr.Close();
}
-
Hello paulliu ,
Could you please ask your question in English?
-
Hi paulliu ,
What version of Nx you are using?
Please sign in to leave a comment.
Comments
3 comments