Forum Discussion

KenCasser's avatar
KenCasser
Qrew Cadet
7 years ago

API_AddRecord works, API_GenAddRecordForm doesn't.

API_GenAddRecordForm works fine for me when calling it from a webpage, but from my javascript page I only seem able to get API_AddRecord to work, but it doesn't take me to the record after generating it.  And, when I try API_GenAddRecordForm from Postman, instead of a qdbapi error report I get thousands of lines of html code.  My goal is to generate a new record and then view it in Edit mode from my javascript page.  What would be the correct syntax for that API call?  Thank you!

5 Replies

  • Everything is working properly - there is just some confusion over how to use the API calls.

    The vast majority of the API methods return a single XML document as a response. The method API_GenAddRecordForm is an exception as it returns a HTML document as a response and included in this response are links and references to other resources such as JavaScript files, CSS files, font files etc.

    When  API_GenAddRecordForm is loaded from a hyperlink or entered into the address bar of a Browser, the Browser will make additional calls to the other resources and assembles everything into a visible page. However, when Postman loads API_GenAddRecordForm it only grabs the raw HTML response and does not request the other resources nor does Postman render the page (it isn't a browser and doesn't even have a rendering engine).

    This explains everything your report.

    The area where you are probably going astray is that in your JavaScfipt you are probably calling API_GenAddRecordForm using:
    $.get("...?act=API_GenAddRecordForm...") 
    when you should be using:
    document.location.href = "...?act=API_GenAddRecordForm..."  
  • But actually, I'm using :

    var url = "https://xxxx.quickbase.com";  
      url    += "/db/";
      url    += "abcdefghi";
      url    += "?a=API_AddRecord";

    and then the url gets called from $.ajax

    so now I'll try rewriting the javascript without the .ajax 
    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      That API call returns XML which is not human readable. The XML response to API_AddRecord needs to be parsed with JavaScript to determine if the record was actually added without error (it normally is so you often just skip this step and proceed to the next step in the workflow).
    • KenCasser's avatar
      KenCasser
      Qrew Cadet
      Honestly, I'm not sure what that means (as previously mentioned, I'm a self-taught hack), BUT - your answer worked!  I got it to do what I wanted it to do.  Thank you thank you!