1

当尝试使用 getUrl() 从具有基本 .htaccess 授权的 URL 获取 CSV 文件时,我被重定向到 AMAZON S3 位置。getURL() 函数将原始 HTTP 标头(用于身份验证)传递给 Amazon S3,Amazon 认为这是一个 Amazon 令牌;这会导致响应中出现以下错误:

只允许一种身份验证机制;仅应指定 X-Amz-Algorithm 查询参数、签名查询字符串参数或授权标头

除了 Thompson Reuters 的咨询之外,我看不到其他任何地方讨论过这个问题:https://community.developers.thomsonreuters.com/questions/29247/aws-download-x-direct-download-returns-invalid-arg。 html

解决方法是从远程服务器接收重定向,查看响应并提取新的(重定向的)URL,然后从那里获取 CSV 文件,而不在标头中包含身份验证详细信息。

洪水脚本 ZOHO 有没有办法做到这一点?getUrl() 函数看起来非常基本,文档也很薄。

另一种方法是使用 CURL 的“中间件”应用程序,将 CSV 保存在远程服务器上,然后使用 ZOHO getUrl() 提取这些 CSV 文件。这不是最佳解决方案,但除非 ZOHO 允许访问某些 HTTP 客户端功能,否则我看不到其他方法。

4

2 回答 2

1

要获取包含detailed:true在 invokeurl 请求中的响应标头的详细信息。

例子:
// parameters is a Map
// header is a Map

response = invokeurl
[
    url :url
    type :POST
    parameters:parameters
    headers:header
    detailed:true
];

// To see all headers and content
info response;

// To see the http response code
info response.get('responseCode');

// With detailed:true any html or json returned will be put in responseText
// info response.get('responseText');

// To see the all http response headers
info response.get('responseHeader');

// To see a specific http response header
// Note: case matters in the response headers name
// "Content-Type" won't find "content-type"
info response.get('responseHeader').get('content-type');

// was the url redirected to another url?
info response.get('responseHeader').get('location');

// get the redirect url
redirect_url = response.get('responseHeader').get('location')

从那里您可以处理重定向 url 并将其传递给下一个 http 请求。

推荐:

在工作了几个月包括detailed:true和不包括它之后,我现在倾向于总是包括它。 detailed:true包含更多有用的信息并具有有用的常规结构:{responseCode: <code>, responseHeaders: <headers>, responseText: <returned-data>}.

于 2021-01-12T22:31:10.587 回答
0

这在 Deluge 中可以使用调用 URL 任务 - https://www.zoho.com/deluge/help/web-data/invokeurl-task.html#response

invokeURL 可以将响应标头移交给您,您可以从中获取重定向 URL,然后继续进行身份验证。

注意:如果您还有其他问题,请告诉我们或联系 support@zohodeluge.com。我们很乐意帮助您。

于 2020-01-02T13:36:18.240 回答