I have a SharePoint 2013 page that I want to make updates to a hyperlink field in a list. I'm calling the REST API using JavaScript + jQuery.
My code (my hyperlink field is Timesheet_x0020_Page):
self.UpdateTimesheet = function(id, state) {
var data = {
'__metadata': { 'type': 'SP.Data.TimesheetListItem' },
'Timesheet_x0020_Page': 'http://google.com, Google',
'State': state
};
var url = "/_api/Web/Lists(guid'e95f5b86-64dd-41d9-9973-493d906ce75e')/Items(" + id + ")";
var promise = $.ajax({
'url': url,
type: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(data),
headers: {
"Accept": "application/json;odata=verbose",
"X-HTTP-Method": "MERGE",
"IF-MATCH": "*",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
}
});
return promise;
};
But I get the following error:
{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected."}}}