I need some help with updating a record after a form submit.
The following code work nicely, except it exposes the API Key. My understanding is this is an object update.
$(document).on('knack-record-create.view_1084', function(event, view, record) {
$.ajax({
url: "https://api.knackhq.com/v1/objects/object_79/records/" + record.id,
type: "PUT",
headers: {
"X-Knack-Application-Id": KnackAppID,
"X-Knack-REST-API-Key": KnackAPIKey
},
data: {
field_760 : NewDescription,
},
success: function(response) {
console.log("Done!");
alert(record.field_760_raw);
}
});
});
I have tired converting to using a View Update using the following code and it does not work.
$(document).on('knack-record-create.view_1084', function(event, view, record) {
$.ajax({
url: "https://api.knack.com/v1/pages/scene_556/views/view_1084/records/"+record.id,
type: "PUT",
headers: {
"X-Knack-Application-Id": KnackAppID,
"Authorization": Knack.getUserToken()
},
data: {
field_760 : NewDescription,
},
success: function(response) {
console.log("Done!");
alert(NewDescription);
}
});
The alert shows the correct data to be saved, however it does not make the change using the second set of code.
Thanks
Martin