Tejas Suthar
Tejas Suthar

Reputation: 296

Want to remove Id field from Trello API Response

Here is Twilio API Call I am using.

My Request: https://api.trello.com/1/boards/boardID/cards/cardId?fields=name&key=MYKEY&token=MYTOKEN

My Response: {"id":"570666201ffd1e340fb2e7f8","name":"query: show the creator of a card","checkItemStates":[]}

What I want: I need to remove Id coming from response. And just want name ad checkedItemStates field.

Expected Response: {"name":"query: show the creator of a card","checkItemStates":[]}

Is this possible?

Update: I am importing response coming from API call to GoogleSpread sheet with provided Google Script available here. https://medium.com/@paulgambill/how-to-import-json-data-into-google-spreadsheets-in-less-than-5-minutes-a3fede1a014a#.q6wzya2yf

I am adding this equation to google spreadsheet cell

=ImportJSON("TRELLO API CALL - mentioned above ", "", "noInherit, noTruncate")

I am not using any kind of language as JSON response is directly going to google script.

Upvotes: 0

Views: 184

Answers (1)

Patrick
Patrick

Reputation: 5866

You can try something like this instead ... but you may need to modify this a bit to fit your needs.

function ImportJSON() {

  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var sheet = ss.getActiveSheet();

  var url = "https://api.trello.com/1/boards/boardID/cards/cardId?fields=name&key=MYKEY&token=MYTOKEN";

  var response = UrlFetchApp.fetch(url); // Get the raw JSON

  var dataSet = JSON.parse(response.getContentText()); // Parse it

  var rows = new Array();

  for (i = 0; i < dataSet.length; i++) {
    var data = dataSet[i];
    rows.push([data.name,data.email]); // your actual JSON entities here ... do not include "id"
  }

  dataRange = sheet.getRange(1, 1, rows.length, 3); // 3 being the total number of entities

  dataRange.setValues(rows);

}

Upvotes: 0

Related Questions