How can I post JSON data to a localhost port?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
valuex
Posts: 86
Joined: 01 Nov 2014, 08:17

How can I post JSON data to a localhost port?

19 Oct 2017, 08:32

curl localhost:8765 -X POST -d "{\"action\": \"guiAddCards\", \"I am using anki-connect to communicate with Anki, a spaced repetition software.
Using python, a GUI window can be initialized with following command.

Code: Select all

import requests
import json
r = requests.post('http://localhost:8765', data=json.dumps({'action': 'guiAddCards', 'version': 5}))
print(r.text)
And I want to show the GUI window with autohotkey.
This is what I've tried, but failed.
Please share me what is the right way.

Code: Select all

#include c:\Users\123\Desktop\JSON.ahk
JSON := new JSON
 oHttp := ComObjCreate("Msxml2.XMLHTTP")
Site:="http://localhost:8765/"
oHttp.open("Post",Site,0)
str:=JSON.Dump([{"action":"guiAddCards"},{"version":2}])
oHttp.send(str)
\": 5}"

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Google [Bot], jameswrightesq and 287 guests