gpt4 book ai didi

rest - 在 Go 语言中执行 POST 请求时出现 403 forbidden 错误

转载 作者:数据小太阳 更新时间:2023-10-29 03:41:56 24 4
gpt4 key购买 nike

//Send put request with given params
func SendPostRequest(url string, param map[string]interface{}, authToken string) string{

//to disable security check
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
//Parse to json
jsonValue, _ := json.Marshal(param)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonValue))
req.Header.Add("Content-Type", "application/json")
req.Header.Add("AuthToken", authToken)


client := &http.Client{}
resp, err := client.Do(req)
}

这是JSON文件

{"credentials":{"display_name":"win10Test","is_default":"","password":"","username":""},
"defaultschedule":true,"host_info":{"ip":"*.*.*.*"},
"install_agent":false,"is_auth_enabled":false,"is_enabled":true,"is_encrypted":false,
"is_synchable":false,"name":"win10","os_type":"Windows","priority":300,"use_ssl":false}

当我运行代码时,出现以下错误响应状态:403禁止访问

最佳答案

403 是禁止请求 - https://en.wikipedia.org/wiki/HTTP_403

我认为你发送了错误的 authToken

仔细检查。

关于rest - 在 Go 语言中执行 POST 请求时出现 403 forbidden 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53944488/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com