Posted in General by Francisco Espada Tue Mar 08 2016 21:20:31 GMT+0000 (Coordinated Universal Time)·3·Viewed 2,566 times

I want to create a new row in a database. I've tried it in your web and it works, but I don't now where I must put de "dataSourceRow" var into "params" var. Example: ----------------------------------------------------------------------------------------------------------------------- var url = 'https://api.goformz.com:443/v2/datasources/*******************/rows'; var headers = { 'Authorization': 'Basic ***************************' } var dataSourceRow = { 'keyColumn': "DATA1", 'value': "[\"DATA2\",\"DATA3"\]" } var params = { "headers": headers, "dataSourceRow": dataSourceRow } var response = UrlFetchApp.fetch(url, params); ------------------------------------------------------------------------------------------------------------------------- With this code the response is 200, but the row isn't created. Where I must insert de "dataSourceRow" var? Thanks.
Mar 11, 2016

It looks like your code is doing a GET, based on the UrlFetchApp documentation found here. The api request to create a datasource row needs to be an HTTP POST.

You need to specify the method as POST and also the payload within the params object, which would be something similar to this:

var params = {
   "headers": headers,
   "method": 'post',
   "payload": dataSourceRow

Please let us know if this helps, or if you need further assistance.

Mar 16, 2016

It works fine.

Thank you.

marked this as solved
Markdown is allowed