當(dāng)我在收到訪問令牌后在 golang 程序中給出這段代碼時:f, err := ioutil.ReadFile("C:\\Users\\vembu\\Desktop\\hi.txt")ioutil.WriteFile("hi.txt", f, 0x777)r, _ := http.NewRequest("POST", urlStr, bytes.NewBuffer(f)) r.Header.Add("Authorization", "Bearer "+accessobj.Access_token)r.Header.Add("attributes", "{\"name\":\"hi.txt\",\"parent\":{\"id\":\"3098791209\"}}")r.Header.Add("file", "hi.txt")我收到此錯誤:I face &{405 Method Not Allowed 405 HTTP/1.1 1 1 map[Allow:[GET, OPTIONS, HEAD] Content-Type:[text/html;charset=UTF-8] Content-Length:[0] Date:[Thu, 12 Mar 2015 13:07:32 GMT] Age:[0] Connection:[keep-alive] Server:[ATS]] 0xc08200b8c0 0 [] false map[] 0xc08201f2b0 0xc082060980}任何人都可以幫我解決添加屬性和文件名上傳到box帳戶的方法嗎?
Golang代碼上傳文件到個人郵箱賬戶
慕無忌1623718
2021-09-20 21:06:29