【发布时间】:2017-06-24 11:56:36
【问题描述】:
没有用于 Python 的 Podio API 的示例代码,但这是为 Ruby 编写的示例代码:
Podio::Item.update(210606, {
:fields => {
'title' => 'The API documentation is much more funny',
'business_value' => { :value => 20000, :currency => 'EUR' },
'due_date' => { :start => '2011-05-06 11:27:20', :end =>
5.days.from_now.to_s(:db) }
}
})
我一生都想不出如何将它翻译成 Python 3。我尝试过使用字典、列表中的字典、使用字段 ID 和名称等引用字段。但它从来没有实际上更新任何东西。
这是我将上述内容转换为 Python 代码的失败尝试(使用不同的字段,因为我的“错误(API 示例)应用程序”中的字段与示例代码中的字段不同):
newValues = {'fields':{'title': "This is my title",'description_of_problem':
"the not work"}}
try:
podio.Item.update(629783395, newValues['fields'])
print('updating was successful')
except:
print('updating was not successful')
podio 是:
podio = api.OAuthClient(
client_id,
client_secret,
username,
password,
)
我的代码中的'fields' 部分实际上没有任何意义,但我不知道如何处理Ruby 代码的那部分,我怀疑这就是问题所在。该程序总是打印“更新成功”,就好像 Item.update 方法被成功调用一样,但正如我所说,它实际上并没有更新 Podio 中的任何内容。任何人都可以看到有什么问题吗?
【问题讨论】:
-
'fields'是最外层字典中的一个键,但您在发送的实际数据中省略了它。