【问题标题】:Why does createNote on Evernote Python API fail with errorcode 5 (DATA_REQUIRED) though data seems to be provided?尽管似乎提供了数据,为什么 Evernote Python API 上的 createNote 会失败并显示错误代码 5 (DATA_REQUIRED)?
【发布时间】:2018-06-12 02:49:09
【问题描述】:

我是 Evernote python 2.x API 的新手,我正在研究一些示例。我设法在沙盒中创建了一个便笺,但未能创建带有附件的便笺。我按照https://dev.evernote.com/doc/articles/creating_notes.php 中给出的示例代码,我最终调用了

try:
    note = noteStore.createNote(authToken, ourNote)
except Errors.EDAMUserException, edue:
    ## Something was wrong with the note data
    ## See EDAMErrorCode enumeration for error code explanation
    ## http://dev.evernote.com/documentation/reference/Errors.html#Enum_EDAMErrorCode
    print "EDAMUserException:", edue
    return None

ourNote 的参数打印为

Note(contentHash=None, updated=None, created=None, deleted=None, contentLength=None, title='testtitel2', notebookGuid=None, content='<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note>testbody<br /><br />Attachment with hash 3430623163666630303562663662393263386539663366613134636630323736: <br /><en-media type="text/plain" hash="3430623163666630303562663662393263386539663366613134636630323736" /><br /></en-note>', tagNames=None, updateSequenceNum=None, tagGuids=None, active=None, attributes=None, guid=None, resources=[Resource(noteGuid=None, height=None, width=None, alternateData=None, mime='text/plain', updateSequenceNum=None, duration=None, attributes=ResourceAttributes(recoType=None, sourceURL=None, cameraMake=None, timestamp=None, altitude=None, clientWillIndex=None, longitude=None, fileName=None, attachment=None, latitude=None, applicationData=None, cameraModel=None), guid=None, data=Data(body='This is the content of testfile, aaa, bbb\\n\n', bodyHash='40b1cff005bf6b92c8e9f3fa14cf0276', size=44), active=None, recognition=None)])

我来了

EDAMUserException: EDAMUserException(errorCode=5, parameter='[3430623163666630303562663662393263386539663366613134636630323736]')

上面写着DATA_REQUIRED。究竟有什么问题或遗漏?

【问题讨论】:

    标签: python evernote


    【解决方案1】:

    根据错误消息,您缺少 ENML 中的资源。请参阅 this sample code 以确保您正确处理附在便笺上的文件。

    【讨论】:

    • 其实这是我最初使用的一段代码。为了仔细检查,我复制了您提到的示例代码,但仍然得到错误代码 5。所以我认为这是弥补 makeNote 的资源参数的问题。但是从 createNote 调用中参数 ourNote 的内容来看(见我的原帖)我仍然没有看到强制成员丢失。
    【解决方案2】:

    我通过将sample code 中的第 20 行从

    更改来解决了我的问题
    hexhash = binascii.hexlify(resource.data.bodyHash)
    

    hexhash = resource.data.bodyHash
    

    这使它起作用。我不知道 hexlify() 在这里的用途。我会问 Evernote 的人。我原始帖子中错误消息中的参数是“hexlified”哈希。顺便说一句:为了确定 bodyHash,我使用了here 描述的方式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-17
      • 1970-01-01
      • 2014-05-06
      相关资源
      最近更新 更多