Ways to upload pdf file in child notes via etapi #7481
-
|
I wish to ask if there is any etapi endpoint which we can upload pdf file via etapi. I did see an internal endpoint which seems to upload pdf file but it only accepts session token not etapi token. Here are the operations currently seems to be supported by each authentication method:
See more here |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
For attachments, |
Beta Was this translation helpful? Give feedback.
-
|
Hi @eliandoran, thanks a lot for answering. I tried using the 1. Create Attachment Metadatacurl -X POST "http://localhost:37740/etapi/attachments" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ETAPI_TOKEN" \
-d '{
"ownerId": "NOTE_ID_HERE",
"role": "file",
"mime": "application/pdf",
"title": "My Document.pdf",
"position": 10
}'Response: {
"attachmentId": "ATTACHMENT_ID",
"ownerId": "NOTE_ID_HERE",
"role": "file",
"mime": "application/pdf",
"title": "My Document.pdf",
"position": 1,
"blobId": "...",
"dateModified": "...",
"utcDateModified": "..."
}So far this step works fine — the metadata record is created successfully. 2. Upload PDF Contentcurl -X PUT "http://localhost:37740/etapi/attachments/ATTACHMENT_ID_HERE/content" \
-H "Content-Type: application/pdf" \
-H "Authorization: Bearer YOUR_ETAPI_TOKEN" \
--data-binary "@/path/to/your/document.pdf"Error Response: {"status":500,"code":"GENERIC","message":"Cannot set null content to attachmentId '9SISSW0ftKmx'"}It seems the server rejects the binary upload with a “Cannot set null content” error. Could you clarify whether /etapi/attachments/{id}/content is intended for direct binary uploads, and if so, what’s the correct way to send the file data? Thanks a lot. |
Beta Was this translation helpful? Give feedback.
-
|
Wow!! Thanks a lot for having a look!! |
Beta Was this translation helpful? Give feedback.
It should support binary content, according to this test for ETAPI:
Notice the
Content-Typeand theContent-Transfer-Encoding.