AdamKeever1
5 years agoQrew Commander
RESTful API Field Array?
Is it possible to update multiple fields using an array of FIDs with the new RESTful API? ------------------------------ Adam Keever ------------------------------
{"properties": {
"choices": [
"OK",
"NOK",
"N/A"
]
}
Here is what works for a single field using Postman:
POST https://[QBREALM].com/db/[DBID] HTTP/1.0
Content-Type: application/xml
Content-Length:
QUICKBASE-ACTION: API_FieldAddChoices
<qdbapi>
<udata>mydata</udata>
<usertoken>usertoken</usertoken>
<fid>8</fid>
<choice>OK</choice>
<choice>NOK</choice>
<choice>N/A</choice>
</qdbapi>
var dbid = "<your dbid>";
var apptoken = "<your apptoken>";
var fids = [8, 9, 10];
var promise, promises = [];
$.ajaxSetup({data: {apptoken: apptoken}});
_.each(fids, function(fid) {
promise = $.post(dbid, {
act: "API_SetFieldProperties",
fid: fid,
decimal_places: "6"
});
promises.push(promise);
});
$.when(promises).then(function() {
alert("DONE!!!");
});
I have tried using the following with syntax no success:
choices: ["OK", "NOK", "N/A"]
choices: "OK", "NOK", "N/A"
properties: {choices: ["OK", "NOK", "N/A"]}
properties: {choices: "OK", "NOK", "N/A"}
I have also tried swapping the API with API_FieldAddChoices to no avail. Any thoughts?
act: "API_FieldAddChoices",
fid: fid,
choice: "OK"
in the IOL added "OK" to all of the fields listed. So two more iterations adding in "NOK", and "N/A" accomplished updating all of the multiple choice field lists to "OK, NOK, N/A".
I still would like to figure out how to do this is one pass if anyone has any suggestions.