Good morning, I'm trying to set a multiple select (checkbox) SharePoint item via bootstrap form independent of SharePoint's forms. I can get everything to work except passing the joined checkbox values to the SharePoint list item via REST.
<div class="form-group" id="Point-Tags-FG">
<div class="checkbox">
<label><input type="checkbox" name="chkA" value="1">1</label>
</div>
<div class="checkbox">
<label><input type="checkbox" name="chkB" value="2">2</label>
</div>
<div class="checkbox">
<label><input type="checkbox" name="chkC" value="3">3</label>
</div>
</div>
var url = ".../ListName";
var event = $("#Event-Type").val();
var date = $("#Event-Date-Time").val();
var address = $("#Point-Address").val();
var latitude = $("#Point-Latitude").val();
var longitude = $("#Point-Longitude").val();
var description = $("#Point-Description").val();
var tags = [];
if ($('input[name="chkA"]').is(':checked')) {
tags.push("1");
}
if ($('input[name="chkB"]').is(':checked')) {
tags.push("2");
}
if ($('input[name="chkC"]').is(':checked')) {
tags.push("3");
}
var SpecialTags = {"__metadata":{"type":"Collection(Edm.String)"},"results":[tags.join(',')]};
var info = {
__metadata: {type: "SP.Data.ListName"},
PostId: post,
EventValue: event,
Date: date,
Address: address,
Latitude: latitude,
Longitude: longitude,
Description: description,
Tags: SpecialTags
};
var body = JSON.stringify(info);
$.ajax({
type: "POST",
url: url,
contentType: 'application/json',
processData: false,
data: body,
error: function (err) {console.log(err)},
success: function (data) {
alert(Entry Submitted.');
location.reload();
}
});
Unfortunately, every time the function is submitted it results in a console error POST URL 400 (Bad Request). I've looked around at some other examples here and can GET the information I just can't seem to POST it via 2010 which I'm stuck using for now.