HELP! Use API for insert content to a specific document?

Hi everyone, I need some help with using API (I don’t have any knowledge in coding).
I use autohotkey file to run the script like this:

AddToDynalist() {
	InputBox, UserInput, Task,Add to Dynalist inbox:,,350,125 
	If (!ErrorLevel and UserInput <> "")
		; UserInput := UriEncode(UserInput)
		URL := ""
		HttpObj := ComObjCreate("WinHttp.WinHttpRequest.5.1")
		HttpObj.Open("POST", URL, 0)
		HttpObj.SetRequestHeader("Content-Type", "application/json")
		json_str := ({"token":jhbkashdiadadadadad,"file_id":dsaDadasdasddw,"changes":[{"action":insert,"parent_id":QLCcIAjcs7wLRlMvDcuFnByN,"content":"ssssssss","checked": false}]})
		Body = json_str
		Result := HttpObj.ResponseText
		Status := HttpObj.Status

Can anybody tell me what wrong with this script because I can run it but it won’t take effect.
Thanks for helping me!!


Herb Caudill posted an AutoHotkey script here. I’m guessing that maybe this script was the basis for your one. Suggest you look at where your script is different from Herb’s because that script works well - I use it myself. In addition, make sure your hotkey isn’t reserved by Windows - by default, ctl+win+p is used by Windows (although the comment in your script refers to ctl+win+l so I’m not sure which one you’re using).

Hi Pottster, thanks for your response.
I’m actually using Herb’s script for adding things to inbox, but I’m finding way to add things to a specific document so I edit his script a bit and tried to follow the example from Dynalist API but it just not work as I showed.
Hope anyone can help!
Thank you a lot.

maybe this : change this line

Body = json_str

to this :

Body := json_str

1 Like

I’m not sure about the autohotkey syntax (so I’m not sure about the difference between := and =, about which @Loic_GENEAU could be 100% correct), but if everything else fails, try to display the Result variable, as that contains the error code if the API does fail.

Maybe hook it up to user output or display an alert?

1 Like

I use this tool for my AutoHotkey scripts. It includes a debugger. Just paste your script in to check for any issues with syntax. Sorry, I don’t have time right now to check it for you and probably best if you do it yourself anyway.

Good luck!