【发布时间】:2019-01-03 04:57:55
【问题描述】:
我正在尝试使用具有凭据的 URL 的请求调用外部 API。
无法从浏览器访问外部 API。
string url = "https://ICSTESTQSic-tkmdlms.integration.ocp.oraclecloud.com:443/ic/api/integration/v1/flows/rest/TSA2ELOQUA_NURTURELEADS/1.0/NurturingLead";
using (var client = new WebClient())
{
NetworkCredential credentials = new NetworkCredential("Username", "Password");
client.Credentials = credentials;
CredentialCache cc = new CredentialCache();
cc.Add(
new Uri(url),
"Basic",
new NetworkCredential("Username", "Password"));
client.Credentials = cc;
using (Stream stream = client.OpenRead(url))
using (StreamReader reader = new StreamReader(stream))
{
MessageBox.Show(reader.ReadToEnd());
}
我想通过从我的 c# 代码发送一个对象作为请求来调用外部 API。 API 已通过身份验证。
【问题讨论】:
-
URL 不是 API。添加单词 REST 仅给出 API 的模糊形状,指定允许的 HTTP 动词。