2012-09-14 37 views
1

我試圖發佈數據回使用VB.NET的體位法的API,vb.net更新體位任務

我能夠檢索沒有問題的數據,但我在努力獲取數據回。以下是我試圖更新任務中的筆記的例子。

Dim add As String = path + "tasks/" + t_id.Text 
     request = WebRequest.Create(add) 

     ' Set the authentication 
     setauth() 
     ' Set type to POST 
     request.Method = "POST" 
     request.KeepAlive = True 
     request.ContentType = "application/x-www-form-urlencoded" 

     data = "-d notes=" + t_notes.Text 
     byteData = UTF8Encoding.UTF8.GetBytes(data) 
     request.ContentLength = byteData.Length 

     'Write(data) 
     Try 
      ps = request.GetRequestStream() 
      ps.Write(byteData, 0, byteData.Length) 
     Finally 
      If Not ps Is Nothing Then ps.Close() 
     End Try 


     response = request.GetResponse() 

我一直在404錯誤,但不知道我哪裏出錯。

回答

0

(我在體位工作)

如果要更新的任務時,你應該使用PUT HTTP方法,不自檢。

+0

感謝您的提示我已經將方法更改爲PUT,並嘗試將contenttype更改爲application/json並通過請求發送爲json字符串: - {「data」:{「notes」:blah blah}}但我沒有收到錯誤的請求錯誤..你有任何提示嗎? –

+0

對不起,延遲迴復(評論不會來到我的收件箱) - 你能告訴我你提出請求的路徑嗎?代碼中「添加」變量的值。 –