Lotusscript NotesHTTPRequest问题 [英] Lotusscript NotesHTTPRequest Issue

查看:167
本文介绍了Lotusscript NotesHTTPRequest问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用LotusScript(Notes客户端版本10.0.1)中的新增Rest功能来从Google检索地址信息.不幸的是,尝试获取响应时出现错误.如果在浏览器中尝试相同的URL,则不会出现任何错误.没有配置代理.

I'm trying to use the new Rest features in LotusScript (Notes Client Release 10.0.1) to retrieve address information from Google. Unfortunately, I get an error when trying to get a response. If I try the same url in the browser, I get no errors. There is no proxy configured.

这是一些示例代码

Dim Session As New NotesSession        
Dim ret As String
Dim URL As String
Dim headers As Variant
Dim webRequest As NotesHTTPRequest
Set webRequest = session.createhttprequest()

url = "https://maps.googleapis.com/maps/api/geocode/json?address=Antwerp&<my Google API key>"

ret  = webrequest.Get(URL)

在代理中运行此代码时,在最后一行出现以下错误:

When I run this code in an agent, I get the following error on the last line:

方法CoerceString中的类型不匹配:未知,预期未知

Type mismatch in method CoerceString: Unknown found, Unknown expected

推荐答案

返回值
变体

返回包含JSON字符串的变体内容.

Returns Variant content which contains JSON string.

您收到的错误消息通常是获取变体并将其转换为字符串的典型消息.

And the error message that you get is typical for getting a variant and trying to cast it to a string.

奇怪的事情:在某些网站上它可以正常工作(可能取决于网站返回的数据类型)

The strange thing: With some websites it seams to work (probably depending of the type of data the website returns) with

Dim ret as String

尽管文档错误地指出该变体包含一个 JSON 字符串(实际上它只包含被调用的网站返回的任何内容,这可能是一个 JSON 字符串,但也可以只是网站的源代码),它仍然是正确的,应该期待有一种变体作为返回值.

Although the documentation is wrong in stating that the variant contains a JSON string (indeed it simply contains whatever the called website returns, that might be a JSON string, but can simply be the source code of the website as well), it still is right, that one should expect a variant as return value.

所以这行应该工作:

Dim ret as Variant

这篇关于Lotusscript NotesHTTPRequest问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆