Clio API:批量操作未返回 303 状态代码
Clio API: bulk actions not returning 303 status code
我没有看到针对 activities
端点使用最新 v4 api 的批量操作的 303 响应。
Make a request to the action with an X-BULK header with the value true. The response will always be a 202 Accepted.
Poll the URL provided in the Location header of the response. This URL is for the Bulk Actions endpoint.
Once the action is complete, polling the URL will return a 303 See Other response.
Download the response from URL in the Location header of the 303 See other response.
这是我正在做的事情:
我向 X-BULK
header 设置为 'true'
的活动端点发出初始请求。
- 我收到了一个
202 Accepted
回复,其中 Location
header 设置为轮询 url。
我开始从 Location
header.
中轮询提供的 url
- 我收到一些
200
回复,其中包含以下数据和 headers:
数据:
{"data":{"id":26952539,"etag":"\"434fa52f83b8e0bb72677f60b8297866\""}}
Headers:
{
'content-type': 'application/json; charset=utf-8',
'transfer-encoding': 'chunked',
connection: 'close',
vary: 'Accept-Encoding',
status: '200 OK',
'last-modified': 'Sat, 02 Dec 2017 22:17:13 GMT',
'x-ratelimit-limit': '50',
'x-ratelimit-reset': '1512253080',
'x-ratelimit-remaining': '45',
'x-request-id': '4674a764-c417-448c-af09-c6dae1cabe15',
etag: '"434fa52f83b8e0bb72677f60b8297866"',
'x-frame-options': 'SAMEORIGIN',
'cache-control': 'no-cache, private, no-store',
'x-xss-protection': '1; mode=block',
'x-api-version': '4.0.5',
'x-content-type-options': 'nosniff',
date: 'Sat, 02 Dec 2017 22:17:13 GMT',
'set-cookie':
[ 'XSRF-TOKEN=oQqTKV8XKRm9oiMuY1OFZ6qleZyRyvtcs9v52%2FWyeiVXxvVszHLiXsQkWelnUHs3ErSsH64ctIpehxErulAWHg%3D%3D; path=/; secure',
'_session_id=7babc5f94bc48ecd5d18d4b40c17d6ca; path=/; secure; HttpOnly' ],
server: 'nginx',
'strict-transport-security': 'max-age=31536000; includeSubdomains'
}
然而 303
永远不会出现。在上面的一些 200
s 之后,我得到另一个 200
和有效载荷:
数据:
{
"data": [
{
"data": [ {id: 1...}, {id: 2...}, {id: 3...}, ... ],
"status": 200
}
],
"status": "completed",
"requested": 46,
"performed": 46
}
Headers:
{
'x-amz-id-2': '1uiNt20Vd/X74JxKZKrt/hah7aof8xfhZlt7fhlDt8b3G2nA47Y8ZDaohb2drSF8ErniirRK2Es=',
'x-amz-request-id': '2B29557952779E29',
date: 'Sat, 02 Dec 2017 22:17:15 GMT',
'last-modified': 'Sat, 02 Dec 2017 22:17:14 GMT',
'x-amz-expiration': 'expiry-date="Wed, 06 Dec 2017 00:00:00 GMT", rule-id="Expiration rule (auto-generated)"',
etag: '"58e33e4eced83d145bf6dec9f72b97be-1"',
'x-amz-server-side-encryption': 'AES256',
'content-encoding': 'utf-8',
'x-amz-version-id': '2Ou7F__59Pz8WKOKZwFg_fOuhQjD5ro0',
'content-disposition': 'attachment; filename="activities 20171202.json";',
'accept-ranges': 'bytes',
'content-type': 'application/json',
'content-length': '9593',
server: 'AmazonS3',
connection: 'close'
}
看来我可以通过测试 status === 'completed'
或什至检查 content-disposition
header.
的存在来充分解决这个问题
我是否做错了什么禁止 303
响应,或者是否存在我忽略的 activities
端点的语义?
测试 status === 'completed'
是否足以解决此问题?
注意:我为每个请求传递 Authorization
header,其中包括访问令牌。
谢谢!
这是 Clio API-V4 的一个已知错误。
此时最好的解决方案是:
正在测试 200
的负载状态 === 'completed'
我们正在努力解决缺少 303 响应的问题。同时我们会更新文档。
这是我一直在使用的解决方法,效果非常好:
查询批量操作状态时使用ignore_redirect
参数:
/api/v4/bulk_actions/?ignore_redirect=true
使用 ?fields=Response_Url
参数获取响应的实际 URL。
从Response_Url
属性下载结果。
这些方法我从来没有失败过。
我没有看到针对 activities
端点使用最新 v4 api 的批量操作的 303 响应。
Make a request to the action with an X-BULK header with the value true. The response will always be a 202 Accepted.
Poll the URL provided in the Location header of the response. This URL is for the Bulk Actions endpoint.
Once the action is complete, polling the URL will return a 303 See Other response.
Download the response from URL in the Location header of the 303 See other response.
这是我正在做的事情:
我向 X-BULK
header 设置为 'true'
的活动端点发出初始请求。
- 我收到了一个
202 Accepted
回复,其中Location
header 设置为轮询 url。
我开始从 Location
header.
- 我收到一些
200
回复,其中包含以下数据和 headers:
数据:
{"data":{"id":26952539,"etag":"\"434fa52f83b8e0bb72677f60b8297866\""}}
Headers:
{
'content-type': 'application/json; charset=utf-8',
'transfer-encoding': 'chunked',
connection: 'close',
vary: 'Accept-Encoding',
status: '200 OK',
'last-modified': 'Sat, 02 Dec 2017 22:17:13 GMT',
'x-ratelimit-limit': '50',
'x-ratelimit-reset': '1512253080',
'x-ratelimit-remaining': '45',
'x-request-id': '4674a764-c417-448c-af09-c6dae1cabe15',
etag: '"434fa52f83b8e0bb72677f60b8297866"',
'x-frame-options': 'SAMEORIGIN',
'cache-control': 'no-cache, private, no-store',
'x-xss-protection': '1; mode=block',
'x-api-version': '4.0.5',
'x-content-type-options': 'nosniff',
date: 'Sat, 02 Dec 2017 22:17:13 GMT',
'set-cookie':
[ 'XSRF-TOKEN=oQqTKV8XKRm9oiMuY1OFZ6qleZyRyvtcs9v52%2FWyeiVXxvVszHLiXsQkWelnUHs3ErSsH64ctIpehxErulAWHg%3D%3D; path=/; secure',
'_session_id=7babc5f94bc48ecd5d18d4b40c17d6ca; path=/; secure; HttpOnly' ],
server: 'nginx',
'strict-transport-security': 'max-age=31536000; includeSubdomains'
}
然而 303
永远不会出现。在上面的一些 200
s 之后,我得到另一个 200
和有效载荷:
数据:
{
"data": [
{
"data": [ {id: 1...}, {id: 2...}, {id: 3...}, ... ],
"status": 200
}
],
"status": "completed",
"requested": 46,
"performed": 46
}
Headers:
{
'x-amz-id-2': '1uiNt20Vd/X74JxKZKrt/hah7aof8xfhZlt7fhlDt8b3G2nA47Y8ZDaohb2drSF8ErniirRK2Es=',
'x-amz-request-id': '2B29557952779E29',
date: 'Sat, 02 Dec 2017 22:17:15 GMT',
'last-modified': 'Sat, 02 Dec 2017 22:17:14 GMT',
'x-amz-expiration': 'expiry-date="Wed, 06 Dec 2017 00:00:00 GMT", rule-id="Expiration rule (auto-generated)"',
etag: '"58e33e4eced83d145bf6dec9f72b97be-1"',
'x-amz-server-side-encryption': 'AES256',
'content-encoding': 'utf-8',
'x-amz-version-id': '2Ou7F__59Pz8WKOKZwFg_fOuhQjD5ro0',
'content-disposition': 'attachment; filename="activities 20171202.json";',
'accept-ranges': 'bytes',
'content-type': 'application/json',
'content-length': '9593',
server: 'AmazonS3',
connection: 'close'
}
看来我可以通过测试 status === 'completed'
或什至检查 content-disposition
header.
我是否做错了什么禁止 303
响应,或者是否存在我忽略的 activities
端点的语义?
测试 status === 'completed'
是否足以解决此问题?
注意:我为每个请求传递 Authorization
header,其中包括访问令牌。
谢谢!
这是 Clio API-V4 的一个已知错误。 此时最好的解决方案是:
正在测试 200
的负载状态 === 'completed'
我们正在努力解决缺少 303 响应的问题。同时我们会更新文档。
这是我一直在使用的解决方法,效果非常好:
查询批量操作状态时使用
ignore_redirect
参数:/api/v4/bulk_actions/?ignore_redirect=true
使用
?fields=Response_Url
参数获取响应的实际 URL。从
Response_Url
属性下载结果。
这些方法我从来没有失败过。