Web services 使用插件调用外部WS
我需要调用一个外部webapi Think get方法和一个插件 我正在使用dynamics on premise,插件已在沙盒中注册。但我遇到了一个错误:无法连接到远程服务器 示例代码:Web services 使用插件调用外部WS,web-services,crm,Web Services,Crm,我需要调用一个外部webapi Think get方法和一个插件 我正在使用dynamics on premise,插件已在沙盒中注册。但我遇到了一个错误:无法连接到远程服务器 示例代码: var uri = new Uri("http:......../api/v1/contact"); var request = WebRequest.Create(uri); request.Method = WebRequestMethods.Http.Get; request
var uri = new Uri("http:......../api/v1/contact");
var request = WebRequest.Create(uri);
request.Method = WebRequestMethods.Http.Get;
request.Timeout = 20000;
request.Headers.Add("DENTITY:{login:login1,password:pass1}");
request.ContentType = "application/json";
try
{
string helloWorldString = "";
using (var response = request.GetResponse())
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
string tmp = reader.ReadToEnd();
helloWorldString = JsonConvert.DeserializeObject<string>(tmp);
Debug.Print("I read this string {0}: ", helloWorldString);
}
}
}
catch (Exception ex)
{
throw;
}
var uri=新uri(“http:../api/v1/contact”);
var request=WebRequest.Create(uri);
request.Method=WebRequestMethods.Http.Get;
请求超时=20000;
Add(“DENTITY:{login:login1,密码:pass1}”);
request.ContentType=“application/json”;
尝试
{
字符串helloWorldString=“”;
使用(var response=request.GetResponse())
{
使用(var reader=newstreamreader(response.GetResponseStream())
{
字符串tmp=reader.ReadToEnd();
helloWorldString=JsonConvert.DeserializeObject(tmp);
Print(“我读取了这个字符串{0}:”,helloWorldString);
}
}
}
捕获(例外情况除外)
{
投掷;
}