[英]SAS API request produces “illegal character” error
我正在尝试使用需要登录的地理编码器通过代理从公司网络内对地址进行地理编码。 在浏览器中,我只需要在第一次尝试时输入一次登录凭据。
我之前已经将下面的代码用于不同的地理编码器(没有身份验证),它工作得很好。 我把它作为上一个问题的答案。 但是,对于这个,它返回以下错误:
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;
这通常意味着在请求期间出现了问题,并且站点没有返回 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
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.