Discussions

Save a responseText to field after API Post request

  • 1.  Save a responseText to field after API Post request

    Posted 02-12-2019 10:26
    I have created a code page to handle following post request: 
    $.ajax({
               type: 'POST',
               url: "https://API.Endpoint";,
               processData: true,
               data: {login: "XXXXX", password: "XXXX"},
               dataType: "json",
               success: function (data) {
                   processData(data);
               }
    });
     
    function processData(data){
     
     //Do some stuff with the data

    }


    I get a reponse like following: 
    1. {readyState: 1, setRequestHeader: ?, getAllResponseHeaders: ?, getResponseHeader: ?, overrideMimeType: ?, ...}
      1. abort: ? (a)
      2. always: ? ()
      3. complete: ? ()
      4. done: ? ()
      5. error: ? ()
      6. fail: ? ()
      7. getAllResponseHeaders: ? ()
      8. getResponseHeader: ? (a)
      9. isRejected: ? ()
      10. isResolved: ? ()
      11. overrideMimeType: ? (a)
      12. pipe: ? (a,b,c)
      13. progress: ? ()
      14. promise: ? (a)
      15. readyState: 4
      16. responseText: "{"returnCode":"9999","return":" response generated and valid until .","returnData":null,"sessionData":"XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX"}"
      17. setRequestHeader: ? (a,b)
      18. state: ? ()
      19. status: 200
      20. statusCode: ? (a)
      21. statusText: "OK"
      22. success: ? ()
      23. then: ? (a,b,c)
      24. __proto__: Object

    I need to save the 16. responseText to a table, more specifically the "sessionData" to a field.
    The "sessionData" contains a token, which I need to use in other API calls from inside quickbase.

    How can I retrieve the sessionData in Quickbase and store it to a field, using the same code page as described above ?


    Thanks in advance