Мне пришлось реализовать его с помощью javascript.Отправить запрос с телом в модель
У меня есть этот класс:
Public Class RecommendedJobsData
Public Property searchedJobsList As List(Of JobInfo)
Public Property jobFromStorage As JobInfo
Public Property totalJobsCount As Integer
Public Property adType As AdType
Public Sub New() ' default constructor
End Sub
' constructor with parameters
Public Sub New(searchedJobsList As List(Of JobInfo), jobFromStorage As JobInfo, totalJobsCount As Integer, adType As AdType)
Me.searchedJobsList = searchedJobsList
Me.jobFromStorage = jobFromStorage
Me.totalJobsCount = totalJobsCount
Me.adType = adType
End Sub
End Class
Я пытаюсь отправить пост запрос к этой функции:
<JsonpFilter()>
Public Function GetToken(header As RequestHeader, body As RecommendedJobsData) As String
Return String.Empty
End Function
Так я использовал JavaScript:
var http = new XMLHttpRequest();
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {//Call a function when the state changes.
if (http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(apiParams);
Заголовок является прошел нормально, но корпус не ...
Он вводит конструктор по умолчанию вместо конструктора, который получает параметры, а затем в объекте body есть GetToken
.
Это apiParams:
Любая помощь приветствуется!