[英]HTTP PUT REQUEST TO API
HI am trying to make an HTTP PUT request to my API.您好正在尝试向我的 API 发出 HTTP PUT 请求。 I am getting back the error 405 and 415 depending on how I change the URL.根据我更改 URL 的方式,我将返回错误 405 和 415。
The ID I am trying to change is 26 and I want to change the testDesc
to test5
.我要更改的 ID 是 26,我想将testDesc
更改为test5
。
Any ideas?有任何想法吗? Thank you for your time.感谢您的时间。
function httpPut() {
$.ajax({
url: "https://someurl/Test/26",
type: "PUT",
'data': {
testDesc: "test5",
},
}).done(function(data) {
document.getElementById("testingBox7").innerHTML = JSON.stringify(data);
});
};
I found a solution:我找到了一个解决方案:
function httpPut(newName) {
var myString = "https://https://someurl/Test/";
$.ajax({
url: myString + newName,
type: "PUT",
processData: false,
contentType: "application/json; charset=UTF-8",
data: JSON.stringify(data)
}).done(function(data) {
document.getElementById("testingBox7").innerHTML = JSON.stringify(data);
});
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.