Currently, the resource-related joplin api can only create resources, but cannot modify them through the api. Can this be supported so that external tools can update resources?
The vscode plugin creates a temporary file for the resource and updates the resource via the joplin api after modification
I tried to update via form-data, but it doesn't seem to work, I looked at the implementation, it seems that PUT must pass data, which is wrong, maybe just modify some resource's properties, such as the resource's title @laurent
The PUT call has the same structure as the POST one - you can pass file and optionally some metadata, like resource title, etc. For me that was working fine, are you getting any error?
At least with Joplin 2.7.13, it was possible to modify the title only. However, there might be different behaviour due to the latest changes:
# creating a resource like described in https://joplinapp.org/api/references/rest_api/#post-resources -> success
curl -F 'data=@./test/grant_authorization_button.png' -F 'props={"title":"my resource title"}' http://localhost:41184/resources?token=<YOUR_TOKEN>
# omitting the props field -> fails with HTTP 500
curl -F 'data=@./test/grant_authorization_button.png' http://localhost:41184/resources?token=<YOUR_TOKEN>
# modifying the resource title only -> succeeds
curl -X PUT -F 'props={"title":"another title"}' http://localhost:41184/resources/<RESOURCE_ID>?token=<YOUR_TOKEN>
# modifying the resource data only -> fails with HTTP 500
curl -X PUT -F 'data=@./test/another_image.png' http://localhost:41184/resources/<RESOURCE_ID>?token=<YOUR_TOKEN>
# modifying the resource data and title -> succeeds, but doesn't update the resource data
curl -X PUT -F 'data=@./test/another_image.png' -F 'props={"title":"my resource title"}' http://localhost:41184/resources/<RESOURCE_ID>?token=<YOUR_TOKEN>
Oh, indeed there's a regression then. I forgot it was possible to modify resource attributes using PUT. I'll update this to restore the previous behaviour.
Sorry, I copied the wrong thing, I was referring to the mistake of using put /resources/id to modify the resource content but also reset the resource title