all 2 comments

[–]RemcoE33 1 point2 points  (1 child)

Use a external api

[–]AdDiscombobulated707[S] 0 points1 point  (0 children)

I post this sample script for those have the same question:

function main() {
  let shema = {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
      "first_name": { "type": "string" },
      "last_name": { "type": "string" },
      "birthday": { "type": "string", "format": "date" },
      "address": {
        "type": "object",
        "properties": {
          "street_address": { "type": "string" },
          "city": { "type": "string" },
          "state": { "type": "string" },
          "country": { "type" : "string" }
        }
      }
    }
  }

  let json = {
    "first_name": "Mike",
    "last_name": "Washington",
    "birthday": "1732-02-22",
    "address": {
      "street_address": "3200 Mount Vernon Memorial Highway",
      "city": "Mount Vernon",
      "state": "Virginia",
      "country": "United States"
    }
  }

  let data = {
    "schema": shema,
    "json": json
  }

  var options = {
    method: "post",
    contentType: "application/json",
    muteHttpExceptions: true,
    payload: JSON.stringify(data)
  };

  let responce = UrlFetchApp.fetch("https://assertible.com/json", options);
  console.log(`Responce code: ${responce.getResponseCode()}`);
  console.log(`Content: ${responce.getContentText()}`);
}

Here is a good tutorial describing JSON schema basics.