尽管似乎提供了数据,为什么Evernote Python API上的createNote失败并显示错误代码5(DATA_REQUIRED)?

问题描述 投票:0回答:2

我是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
2个回答
0
投票

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


0
投票

我通过更改sample code中的第20行解决了我的问题

hexhash = binascii.hexlify(resource.data.bodyHash)

hexhash = resource.data.bodyHash

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

© www.soinside.com 2019 - 2024. All rights reserved.