Skip to main content
Question

API_UploadFile with JSON data

  • August 16, 2017
  • 0 replies
  • 91 views

Hey!
Probably a stupid question but I can figure out is there is a way to provide JSON data to an API_UploadFile call. At the moment I use xml data like this:
var req = "";
req += "<qdbapi>";
req += "<apptoken>" + QBU_apptoken + "</apptoken>";
req += "<rid>1</rid>";
req += "<field fid='6' filename='" + fineName" + "'>";
req += fileContent;
req += "</field>";
req += "</qdbapi>";
$.ajax({
    url: QBU_tabledbid + "app?act=API_UploadFile",
    type: 'POST',
    data: req,
    contentType: "text/xml",
    dataType: "xml",
    processData: false
});
But I would prefer something like 
$.post(QBU_tabledbid, {
    act: "API_UploadFile",
    rid: 1,
    field: {
        fid: 6,
        filename: fileName,
        value: fileContent
    }
}) 
but I am struggling to find the correct syntax...
Thank you!
Adrien
This topic has been closed for replies.

Please first validate your JSON data using these tools.


  • Registered
  • August 16, 2017
QuickBase's API are skewed towards using XML for both the request and response. There is no JSON supported in the API. You could write a wrapper around their API that consumed JSON but it would be a very thin wrapper and probably would not be worth the effort in just this one instance of preferring JSON over XML.

That said you can upload files using Fetch and the FormData API as demonstrated here for copying file attachments between files.

https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=574

This script does not even use the QuickBase API and it demonstrates that advances in the browser and web technologies are making old ways of doing things obsolete. You will not take advantage of the bounty of new features and technologies that are in your browser unless you stop relying on old ways of doing things. 

Dan, you did it again... This was exactly the situation I was looking for.

Your notation for the URLs, you're using the URL notations of just queries/edit records like the native QB UI does... so you're not even using the actual API right?