处理请求流时出错。 JSON 指定的文本无效

Error processing request stream. JSON text specified is not valid

我使用了这个代码

function updateListItem(itemId, listName, siteUrl, title, success, failure) {    
var metatdata = "{ '__metadata': { 'type': 'SP.Data.TestListListItem' }, 'Title': "+title+"}"
getListItemWithId(itemId, listName, siteUrl, function (data) {
    $.ajax({
        url: data.__metadata.uri,
        dataType: "json",
        contentType: "application/json;odata=verbose",
        method: "POST",
        body: metatdata,
        headers: {
            "Accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "Content-Length":metatdata.length,
            "X-HTTP-Method": "MERGE",
            "If-Match": "*"
        },
        success: function (data) {
            alert("success in ajax");
            console.log("Item in success ajax");
            console.log(data);
            success(data);
        },
        error: function (data) {
            alert("waiting for success in ajax");
            console.log("Item in error ajax");
            console.log(data);
            failure(data);
        }
    });
}, function (data) {
    failure(data);
});

当我使用控制台检查它时,它显示 "Error processing request stream. JSON text specified is not valid",我想我无法从 JSON 响应中读取文本值,我尝试 lot.Please 帮助我的人。 .提前致谢

function updateListItem(itemId, listName, siteUrl, title, success, failure) {


getListItemWithId(itemId, listName, siteUrl, function (data) {
    var item = { '__metadata': { 'type': 'Microsoft.SharePoint.DataService.TestListItem' }, 'Title': title };
    $.ajax({
        url: data.__metadata.uri,
        type: "POST",
        contentType: "application/json;odata=verbose",
        data: JSON.stringify(item),
        headers: {
            "Accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "X-HTTP-Method": "MERGE",
            "If-Match": data.__metadata.etag
        },
        success: function (data) {
            success(data);
        },
        error: function (data) {
            failure(data);
        }
    });
}, function(data){
    failure(data);
});
}
function getListItemWithId(itemId, listName, webUrl, success, failure) {
$.ajax({
    url: webUrl + "/_vti_bin/listdata.svc/" + listName + "(" + itemId + ")",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
        success(data.d);
    },
    error: function (data) {
        failure(data.responseJSON.error);           
    }
});
}