我有一个webapi,我使用WebClient DownloadString方法从中获取JSON数据。
当我在浏览器中运行URL时,我得到了JSON响应,但是当我使用SSIS包运行它时,它在DownloadString调用时失败并出现以下错误。
[下载Json]错误:下载失败:远程服务器返回错误:(502)Bad Gateway。
我的代码是
using (var mySSISWebClient = new System.Net.WebClient())
{
mySSISWebClient.Headers[HttpRequestHeader.Accept] = "application/json";
var result = mySSISWebClient.DownloadString(jsonURL);
}
我在浏览器中输入jsonURL时得到的实际文本是
{"SEARCHRESPONSE":{"STATUS":"failed","SEARCHTERM":"*:*","SUGGESTION":"","DESCRIPTION":"<!DOCTYPE html>\n<html>\n<head>\n<title>Error</title>\n<style>\n body {\n width: 35em;\n margin: 0 auto;\n font-family: Tahoma, Verdana, Arial, sans-serif;\n }\n</style>\n</head>\n<body>\n<h1>An error occurred.</h1>\n<p>Sorry, the page you are looking for is currently unavailable.<br/>\nPlease try again later.</p>\n<p>If you are the system administrator of this resource then you should check\nthe error log</a> for details.</p>\n</body>\n</html>\n"}}
请帮助我找到原因。