The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Has anyone set up an API to have Google Sheets GET information from a table. For example, how hard is it to run a job that will update a Google Sheets file with the current data in the incident table?

cjdiaz
Kilo Contributor

Has anyone set up an API to have Google Sheets GET information from a table. For example, how hard is it to run a job that will update a Google Sheets file with the current data in the incident table?

1 ACCEPTED SOLUTION

It would be a GET.   You'll want to go to script.google.com and create a script that looks something like the below to fetch the data.   This example is pulling everything in the incident table.   Parsing the json and loading it into a sheet I think is beyond the scope of this forum.   There's a lot of info out there about how to do this once you've got the json.



function myFunction() {


  url = "https://dev15112.service-now.com/api/now/table/incident"


 


  var options = {


      "headers":


      {


          "Authorization": "Basic " + Utilities.base64Encode("user:password"),


          "contentType": "application/json"


      }


  };


 


  var response = UrlFetchApp.fetch(url,options);


  // Here you can see what the response was


  Logger.log(response);


}


View solution in original post

6 REPLIES 6

It would be a GET.   You'll want to go to script.google.com and create a script that looks something like the below to fetch the data.   This example is pulling everything in the incident table.   Parsing the json and loading it into a sheet I think is beyond the scope of this forum.   There's a lot of info out there about how to do this once you've got the json.



function myFunction() {


  url = "https://dev15112.service-now.com/api/now/table/incident"


 


  var options = {


      "headers":


      {


          "Authorization": "Basic " + Utilities.base64Encode("user:password"),


          "contentType": "application/json"


      }


  };


 


  var response = UrlFetchApp.fetch(url,options);


  // Here you can see what the response was


  Logger.log(response);


}


cjdiaz
Kilo Contributor

Just what I needed. Thanks Dan!