Я пытаюсь вызвать свой веб-сервис в Sitefinity с помощью ajax. У меня нет проблем с получением членов команды с помощью этого вызова:
$.ajax({
url: "http://localhost:60556/api/lawyerswebservice/teammembers",
method: 'Get',
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Bearer " + accessToken);
},
success: function (data) {
console.log(data);
dataObject = data;
},
error: function (err) {
console.log(err.responseText);
}
})
Однако, когда я делаю вызов ниже, он возвращает ошибку 500, говорящую, что ссылка на объект не установлена на экземпляр объекта. Я знаю токен доступа, если он в порядке. По какой-то причине, мне не кажется, что я пытаюсь публиковать на этот URL, но именно это Sitefinity говорит, что они хотят, чтобы я публиковал.
$.ajax({
url: "http://localhost:60556/api/lawyerswebservice/teammembers",
method: 'POST',
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Bearer " + accessToken);
},
processData: false,
contentType: "application/json",
data: JSON.stringify({
"PublicationDate": "2019-12-11T15:24:17.9479664Z",
"UrlName": "sample string 2",
"Title": "sample string 3",
"Speaking": "sample string 4",
"MiddleName": "sample string 5",
"Teaching": "sample string 6",
"Gender": "sample string 7",
"Prefix": "sample string 9",
"FirstName": "sample string 10",
"LastName": "sample string 11",
"Suffix": "sample string 12",
"Designations": "sample string 13",
"PositionTitle": "sample string 14",
"EmailAddress": "sample string 15",
"PrimaryPhoneNumber": "sample string 16",
"SecondaryPhoneNumber": "sample string 17",
"FaxNumber": "sample string 18",
"LinkedInProfileURL": "sample string 19",
"TwitterProfileURL": "sample string 20",
"OtherSocialMediaProfileURL": "sample string 21",
"Content": "sample string 22",
"ShortBio": "sample string 23",
"ContentMeta": "sample string 24",
"Memberships": "sample string 25",
"SeoTitle": "sample string 26",
"SeoDescription": "sample string 27",
"SeoKeywords": "sample string 28",
"CustomSortOrder": "29.0",
"Media": "sample string 30",
}),
success: function () {
console.log("success");
},
error: function (err) {
console.log(err);
}
})