Operating system
Windows
Joplin version
3.1.24
What issue do you have?
In the section of the documentation dedicated to creating new resources POST /resources there is a phrase:
The "data" field is required, while the "props" one is not. If not specified, default values will be used.
I admit that it can only refer to the PUT /resources/:id
method described in parallel. But when I first read the documentation, I attributed this statement to the POST /resources
method as well.
When my program refused to work, I did a number of experiments:
-
200 OK
curl -F data=@image.jpeg -F "props={\"title\": \"my resource title\"}" http://localhost:41184/resources?token=some_token
-
200 OK
curl -F data=@image.jpeg -F "props={}" http://localhost:41184/resources?token=some_token
-
500 Internal Server Error
curl -F data=@image.jpeg http://localhost:41184/resources?token=some_token
It follows that for the POST /resources
method the props
data block (even if empty) is absolutely necessary.
2024-12-20 20:24:27: Request: POST /resources?token=some_token
2024-12-20 20:24:27: [error] SyntaxError: Unexpected end of JSON input
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Object.bodyJson (C:\Program Files\Joplin\resources\app.asar\node_modules\@joplin\lib\services\rest\Api.js:130:43)
at Object.default_1 [as fn] (C:\Program Files\Joplin\resources\app.asar\node_modules\@joplin\lib\services\rest\routes\resources.js:63:38)
at Api.route (C:\Program Files\Joplin\resources\app.asar\node_modules\@joplin\lib\services\rest\Api.js:151:37)
at execRequest (C:\Program Files\Joplin\resources\app.asar\node_modules\@joplin\lib\ClipperServer.js:161:54)
at C:\Program Files\Joplin\resources\app.asar\node_modules\@joplin\lib\ClipperServer.js:192:34
at C:\Program Files\Joplin\resources\app.asar\node_modules\@joplin\lib\node_modules\multiparty\index.js:139:9
at C:\Program Files\Joplin\resources\app.asar\node_modules\@joplin\lib\node_modules\multiparty\index.js:118:9
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)