【发布时间】:2018-04-17 06:05:36
【问题描述】:
我想将带有 Autohotkey 的字符串发布到 Rest API。
在另一个问题上,我发现了这样的内容:
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
所以这是我的问题:我将身份验证信息放在哪里? 我读到,我已经将字符串 username:password 编码为 Base64 提供给 API,但是在哪里?非常感谢。
文档中的示例是(使用 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
我的 json_string 是:
{"type":"page","title":"new page","ancestors":[{"id":13533694}, "space":{"key":"SPIELWIESE"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}
怎么了?
【问题讨论】:
-
欢迎来到 SO。不要用德语发帖。坚持英语。还请校对您的问题并在此处查看:stackoverflow.com/help/how-to-ask
标签: rest api autohotkey