自訂 API Header
如果在使用 SDK 的環境中,因資安或相關規定,所有 API 皆需要加上特定的 Header 才能使用,則可以透過下列方式進行:
using Ede.Uofx.PubApi.Sdk.NetStd.Service;
//設定金鑰
UofxService.Key = "xxx";
//設定 UOF X 站台網址
UofxService.UofxServerUrl = "https://myuofx.com.tw";
//設定客製 header
UofxService.Security.CustomHeaders.Headers.Add("X-System-Name", "UOFX SDK");
UofxService.Security.CustomHeaders.Headers.Add("header2", "xxx");
僅需在 SDK 運行最初時設定一次,之後所有的 API 皆會套用。
注意
header name 和 value 會依 HTTP/1.1 標準(RFC 2616) 進行檢查。