Updating auth using google script app

Hi Guys, I’m a amateur dev!!

I have managed to use google script app to look at the unlocking and locking in the logs to figure out the time my housekeepers are at the house. Using get of the API

I am now trying to figure out how to use the post parts of the api. I am trying to use the [POST] Updates asynchronous a smartlock authorization

  var url = "https://api.nuki.io/smartlock/179??????????5/auth/62???????????????????40";
  var headers = {
    "Authorization": "Bearer 3b8567?????????????????????????????????????????????????????????????3cac451",
    "contentType": "application/json",
    "headers": {
      "name": "A??????st",
      "allowedFromDate": "2022-04-08T18:00:00.000Z",
      "allowedUntilDate": "2022-04-11T11:00:00.000Z",
      "allowedWeekDays": 0,
      "allowedFromTime": 0,
      "allowedUntilTime": 0,
      "accountUserId": 0,
      "enabled": true,
      "remoteAllowed": false
    }
  };
  var response = UrlFetchApp.fetch(url, headers);
  var smartLocksData = JSON.parse(response.getContentText());

Error message: Exception: Request failed for https://api.nuki.io returned code 401. Truncated server response: {“detailMessage”:“Your access token is not authorized”,“stackTrace”:[],“suppressedExceptions”:[]} (use muteHttpExceptions option to examine full response)

Im using the same authorisation on my GET requests

Im suspecting I need to implement OAuth2 for POST/update request. Is this True?

Does anyone have any Docs to help to do this with google sheets?

I cannot figure this one out. Ive got to here but I cannot seen to invoke the POST call.

Everywhere I put

"method" : "post",

It does not seem to like it.

code below is returning all my auths. I guess its just invoking the Get method

 var url = "https://api.nuki.io/smartlock/auth";
  var headers = {
    "Authorization": "Bearer 45??????????????????????????????????????????????6481",
    };

    var body =  {
      "name": "A?????????t",
      "allowedFromDate": "2022-04-11T07:27:15.131Z",
      "allowedUntilDate": "2022-04-11T07:27:15.131Z",
      "allowedWeekDays": 0,
      "allowedFromTime": 0,
      "allowedUntilTime": 0,
      "accountUserId": 0,
      "enabled": true,
      "remoteAllowed": false,
      "id": "6????????????????????????0"
    }

  var options = {
    headers: headers,
    payload : body
    
  };
  var response = UrlFetchApp.fetch(url, options);
  var smartLocksData = JSON.parse(response.getContentText());
  Logger.log(smartLocksData);

Ive figured it out

var url = "https://api.nuki.io/smartlock/auth";

  var payload = [{
    name: "A??????????t",
    allowedFromDate: "2022-04-11T07:27:15.131Z",
    allowedUntilDate: "2022-04-11T07:31:15.131Z",
    allowedWeekDays: 0,
    allowedFromTime: 0,
    allowedUntilTime: 0,
    accountUserId: 0,
    enabled: true,
    remoteAllowed: false,
    id: "6????????????????????????0"
  }];


  var headers = {

    method: "POST",
    contentType: "application/json",
    headers: {
      Authorization: "Bearer 45?????????????????????????????????????????????????????????????6481",
      accept: "application/json",
    },
    payload: JSON.stringify(payload)
  }

  var response = UrlFetchApp.fetch(url, headers);
  var smartLocksData = response.getResponseCode();
  Logger.log(smartLocksData);