我正在尝试在现有网站上使用SugarCRM v10但是HttpWebRequest.GetResponse不合作。当我去fiddler4和Postman时,url和请求者在代码中是相同的,我得到200响应。到目前为止这是我的代码(这是函数中的代码):
Dim request As HttpWebRequest = Nothing
Dim Reqeuststring As String = myurl
request = Net.HttpWebRequest.Create(Reqeuststring)
request.Method = mymethod
request.ContentType = "application/json"
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(pstring)
request.ContentLength = byteArray.Length
' Get the request stream.
Dim dataStream As Stream = request.GetRequestStream()
' Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length)
' Close the Stream object.
dataStream.Close()
response = request.GetResponse()
我按照API文档传递url(http://{siteurl}/rest/v10/oath2/token
),pString是json格式,在这种情况下,mymethod作为POST传递。