我有一个 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"}}
请帮我找出原因。