我们在尝试获取新任务时当前收到此400错误:
{"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http:\/\/api.podio.com\/task","query_string":"completed=true&completed_on=-5d&fields=completed_on&limit=100&offset=0&sort_by=rank&sort_desc=false&space=3798819","method":"GET"},"error_description":"Invalid token '(files,tags,votes)'","error":"invalid_value"}
只是因为您知道我们不会将其用于内部目的,而是我们有一个集成设置,允许任务同步和完成。
我们正在通过所有空间任务进行分页循环:
get('/task', { space: project_link.remote_id, sort_by: 'rank', limit: limit, offset: offset, sort_desc: false, completed: completed, fields: 'completed_on' })
修改
def sync_project(project_link)
existing_remote_ids = _synced_remote_task_ids(project_link.link_id)
synced_project_ids = []
[{completed: false}, {completed: true}].each do |params|
offset = 0
loop do
tasks, next_offset = tasks_page_for_project(project_link: project_link, offset: offset, **params)
tasks.each do |task|
remote_task = map_podio_task(task, project_link.link_id)
_process_task(remote_task)
synced_project_ids << remote_task[:id].to_s
end
offset = next_offset
break unless next_offset
end
end
_mark_tasks_deleted(existing_remote_ids - synced_project_ids)
end
def tasks_page_for_project(project_link:, offset:, completed: false)
next_offset = nil
limit = 100
params = { space: project_link.remote_id, sort_by: 'rank', limit: limit, offset: offset, sort_desc: false, completed: completed, fields: 'completed_on' }
params[:completed_on] = '-5d' if completed
tasks = get('/task', params)
if tasks.size == limit
next_offset = offset + limit
end
return tasks, next_offset
rescue TaskSync::ProjectRemovedError => ex
raise TaskSync::ProjectRemovedError.new(self, project_link.remote_id), ex.message
rescue TaskSync::TemporaryNetworkError => ex
ex.project_id = project_link.remote_id
raise ex
end
def service
check_token
@service ||= build_client(href, 'Authorization' => "OAuth2 #{token[:token]}")
end
def authorization
params = {
grant_type: 'refresh_token',
client_id: TaskSync.config[:podio][:client_id],
client_secret: TaskSync.config[:podio][:client_secret],
refresh_token: token[:refresh_token]
}
build_client 'https://podio.com/oauth/token', { 'Content-Type' => 'application/x-www-form-urlencoded' }, params
end
def href
'https://api.podio.com'
end
此错误仅发生在单个客户端上。
您能告诉我们这个错误的含义吗?它与OAuth有关还是与其他东西有关?
谢谢!
答案 0 :(得分:1)
感谢您在Podio文档中报告发现的问题。这里有误导性(更新后的文档已经发布)。
completed_on
字段的格式为YYYY-MM-DD-YYYY-MM-DD
例如。对于2017年6月完成的所有任务:2017-06-01-2017-06-30
答案 1 :(得分:-2)
你没有提到你在这里使用的编程语言就是我在PHP上写的一个例子:
require_once 'podio/PodioAPI.php'; //podio library
error_log("validate triggerd");
$client_id = 'your client Id';
$client_secret = 'your client secret';
$app_id = 'your app id';
$app_token = 'your app token';
Podio::setup($client_id, $client_secret);
// Turn on debugging
Podio::$debug = true;
// Authenticate the app
Podio::authenticate('app', array('app_id' => $app_id, 'app_token' => $app_token));
并获取您的项目:
$tasks = PodioTask::get_all( $attributes = array() );