我正在尝试使用需要登录的地理编码器通过代理对公司网络中的地址进行地理编码。在浏览器中,我只需要在第一次尝试时输入一次登录凭据。
我以前将下面的代码用于不同的地理编码器(没有身份验证),它工作得很好。我把它当作是对a previous question的一个回答。但是,对于本例,它返回以下错误:
59 * libref name same as fileref pointing to json content;
60 libname response json;
NOTE: JSON data is only read once. To read the JSON again, reassign the JSON LIBNAME.
ERROR: Invalid JSON in input near line 1 column 1: Encountered an illegal character.
ERROR: Error in the LIBNAME statement.与其他代码相比,我只添加了webusername和webpassword,但是否使用它对错误消息没有影响。除此之外,我只更改了选项set=SSL_SNI_HOSTNAME和url=的URL。
filename response temp;
filename headers temp;
options set=SSL_USE_SNI=1;
options set=SSL_SNI_HOSTNAME="https://geocoder.srv"; /*<-- this might be wrong, i took it from the start of the url */
proc http
url = 'SORRY NOT ALLOWED TO PUT THE URL HERE'
method='GET'
proxyhost = 'OUR WEBPROXY'
webusername = 'USERNAME'
webpassword = 'PW'
proxyport = 8080
out= response
headerout = headers
ct = "application/json";
run;
data _null_;
infile headers;
input;
put _infile_;
run;
data _null_;
infile response obs=10;
input;
put _infile_;
run;
* libref name same as fileref pointing to json content;
libname response json;
proc copy in=response out=work;
run;发布于 2021-02-19 02:42:36
这通常意味着在请求过程中出现了错误,并且站点没有返回JSON文件。要诊断返回的消息,请添加debug语句(info)。使用选项RESPONSE_BODY RESPONSE_TEXT返回日志中的响应。
proc http
url = "www.google.com"
proxyhost = "my proxy"
proxyport = 8080
;
debug RESPONSE_BODY OUTPUT_TEXT;
run;响应:
< <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world's
information, including webpages, images, videos and more.
....您可以通过删除RESPONSE_BODY来进一步简化响应。
NOTE: 200 OK如果您的SAS版本不支持这些选项,您可以通过将响应重定向到您的主目录并打开该文件来执行相同的操作。例如:
filename response "/home/$USER/response.txt";
proc http
url = "www.google.com"
out = response
...https://stackoverflow.com/questions/66264970
复制相似问题