giusto per fare una prova stupida, ho creato un progetto console, e portato quel metodo li dentro:
codice:
Public Function syncAsana(ByVal nome As String) As String
Try
Dim token As String = "TOKEN"
Dim request As WebRequest = WebRequest.Create("https://URL/api/1.0/tasks")
Dim postData As String = "assignee=email@email.com¬es=TEST_NOTES&name=NOME 1&projects=1138221313703500"
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
request.Method = "POST"
request.PreAuthenticate = True
request.Headers.Add("Authorization", "Bearer " & token)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
Diagnostics.Debug.WriteLine(CType(response, HttpWebResponse).StatusDescription)
response.Close()
Return response.ToString()
Catch ex As Exception
Diagnostics.Debug.WriteLine(ex.Message)
Return ex.Message
End Try
End Function
potrebbe essere che il problema sia dovuto al fatto che quel codice sia nel code behind di una pagina aspx?
o che lancio quella funzione da jquery ajax?