API with AHK in Windows

Hello, I really want to use Joplin API via AHK in Windows.

This is what I have so far. It gives me all id's and titles. But I'm fighting to find Joplin documentation for PUT (append) the body of a default note. Anyone that can point me in the right direction?

Another question is: Are there other/better ways to use the API than by PUT and GET ?

I see usage of curl, and some programming. Where to start and where to go ?

oWhr := ComObjCreate("MSXML2.XMLHTTP.6.0")
oWhr.Open("GET", "http://127.0.0.1:41184/notes/?fields=id,title&token=XXXXXXXXXXXXXXXXXXXXXXXX", false)
oWhr.SetRequestHeader("Content-Type", "application/json")
oWhr.Send()
MsgBox, % oWhr.ResponseText

Win, MacOS, IOS, Linux

Joplin 1.4.18 (prod, win32)
Sync Version: 2
Profile Version: 34
Keychain Supported: Yes
Revision: 76c4d99b8 (master)

There's no API to append text to a note, so you'll need to GET the note, add to the body, then PUT the note.

Thank you for the quick reply ! This is fine, like I suspected. The problem is that I also can't find the syntax to PUT (replace) a current body. I suspect it is done via the ID somehow ?

It's like the POST example, except you add an ID:

curl -X PUT --data '{ "title": "My note", "body": "Some note in **Markdown**"}' http://127.0.0.1:41184/notes/SOME_ID

This exact example I have tested. It creates a new note each time I run it. If I get you right, It will not create a new, but update, If I also add the ID ?

I also have not figured out how I change the curl syntax into the MSXML2.XMLHTTP.6.0 syntax.

I tried to paste your curl command into "my code" but It struggles with the quotes.

oWhr.Open("PUT", "curl --data '{ "title": "Hours", "body": "12:30-14:00 Project meeting"}' http://127.0.0.1:41184/notes/1ccb8470d86444529e1ff95442b66ee?token=XXXXXXX", false)

I get "illigal char" ==> "title"" I also tested to escape with a backslash.

I don't know as I haven't used AHK in years and I expect you need to get all the quotes right and escape what should be escaped. For this you might have better luck in the ahk forum.

oWhr := ComObjCreate("MSXML2.XMLHTTP.6.0")
oWhr.Open("PUT", "http://127.0.0.1:41184/notes/1ccb8470d86444529e1ff95442b66ee?token=XXXXXXXXXXXXXXXXXXX", false)
oWhr.SetRequestHeader("Content-Type", "application/json")
oWhr.Send(title="My note"&body="Some note in Markdown")
MsgBox, % oWhr.ResponseText

Sure I might try there instead. However maybee MSXML2.XMLHTTP.6.0 is not the way to run the API. I find little documentation about it. I might try to run commandline with curl command from AHK instead, since Joplin has much more documentation using this method.

I now tried the example with the curl command you linked to.
curl --data '{ "id": "00a87474082744c1a8515da6aa5792d2", "title": "My note with custom ID"}' http://127.0.0.1:41184/notes
However this generates an error message. Unexpected token ' in JSON at position 0
Do you know why ?

This was harder than I expected. Its now midnight local time, I need to rest some. Thanks for your support. Bye for now.

Finally I got it to work on windows. To implement in AHK, still fighting on the AHK forum to find best way to implement. Only the json part should be escaped. Why is this not mentioned in the documentation. I guess it depends on operating system, and documentation is only for Linux. But to me this was not clear.

curl -H "Content-Type: application/json" -X PUT http localhost:41184 /notes/00a87474082744c1a8515da6aa5792d2?token=XXXXX Broken Link for safety -d "{\"title\":\"New Value on Old Post\", \"id\":\"00a87474082744c1a8515da6aa5792d2\"}"