swetha s

swetha s

  • 1.7k
  • 19
  • 5k

Restapi to update choice field with new vvalues dynamically

Apr 27 2018 3:03 AM
I am trying to append dropdown dynamically from textbox.. I am trying to append hardcoded value to choice but I am getting error.. I neeed to append new value. choice fied has values already. please help. its rugnet
$.ajax({
url: endpointUrl + "/_api/web/lists/GetByTitle('Pages')/fields/GetByTitle('CallAction')",
type: "POST",
data: JSON.stringify({
"__metadata": { "type": "SP.Data.PagesItem" },
"CallAction": { "__metadata": { 'type': "SP.FieldChoice" }, "Choices": {results: ["Test1"] }},
}),
headers: {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*",
"X-Http-Method": "PATCH",
},
success: function (data) {
alert("Success");
},
error: function (err) {
alert(JSON.stringify(err));
},
});

Answers (2)