Home Rest API Authentication with Autohotkey
Reply: 0

Rest API Authentication with Autohotkey

user1398
1#
user1398 Published in April 22, 2018, 6:49 am

i want to POST a string with Autohotkey to a Rest API.

On another question i found something like this:

URL := "http://localhost:8000/createPlayer"
HttpObj := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HttpObj.Open("POST", URL, 0)
HttpObj.SetRequestHeader("Content-Type", "application/json")
json_str := ({"name": "Any Name"})
Body = json_str
HttpObj.Send(Body)
MsgBox, %Body%
Result := HttpObj.ResponseText
Status := HttpObj.Status
msgbox % "status: " status "`n`nresult: " result

so here is my Question: where do i put the authentication-information? I read, that i have tho give the string username:password coded as Base64 to the API, but where? Thank u very much.

The Example in the documentation is(with curl):

curl -u admin:admin -X POST -H 'Content-Type: application/json'
-d'{"type":"page","title":"new page",
"ancestors":[{"id":456}], "space":{"key":"TST"},"body":{"storage":
{"value":
"<p>This is a new page</p>","representation":"storage"}}}'
http://localhost:8080/confluence/rest/api/content/ | python -mjson.tool

my json_string is:

{"type":"page","title":"new page","ancestors":[{"id":13533694}, "space":{"key":"SPIELWIESE"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}

what is wrong?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311451 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO