Troubleshooting Data Update Issues with Google Apps Script and Ragic API

Hi everyone,

I’m relatively new here and have been working with the Ragic database for a few months as part of my company’s projects. We’re currently exploring ways to integrate Ragic with other tools and have encountered some issues I hope to get assistance with.

We’ve built a simple web application using Google Apps Script and are attempting to update/create data fields in our Ragic database using the UrlFetchApp.fetch function. Unfortunately, we’re not seeing the expected results. Below is a sample of the code we’re using:

function trial() {
  var apiURL = "https://www.ragic.com/"+companyName+"/dev/3?v=3&api";
  var payload = JSON.stringify({
    "1000916": "test1",
    "1000917": "test2",
    "1000918": "test3"
  });
  var options = {
    "method": "post", //we've also tried "put" method
    "headers": {
      "Authorization": "Basic " + apiKey
    },
    "payload": payload
  };
  
  var response = UrlFetchApp.fetch(apiURL, options);
  Logger.log(response.getContentText());
  Logger.log(response.getResponseCode());
}

A few notes for context:

  • companyName and apiKey are placeholders for global variables that contain actual values.
  • Despite receiving a 200 status code from the UrlFetchApp.fetch response, indicating success, the data in our Ragic database does not appear to be updated or created.
  • Interestingly, we can successfully retrieve data using a similar approach with the UrlFetch function.

I’ve reviewed the documentation and attempted several modifications to the code without success. It’s challenging to pinpoint what I might be missing or doing incorrectly. Has anyone encountered a similar issue or can offer insights into what might be going wrong? Any advice or suggestions would be greatly appreciated.

Thank you in advance for your help!

Hi,

Could you please check if you have entered the right server, which requires changing www to the first three characters of your database URL(eu3, ap5, na4, etc)? For more details, please refer to this document.

Oh!

I didn’t notice that in my latest version of api url, I forgot to use the right server…

(It’s actually because I had it checked by ChatGPT, and it modified this way)

Thank you sooooo much!
My webapp is now fully functioning!

1 Like