I created something like this:
function createRoom() {
var accessToken = "YOUR_ACCESS_TOKEN";
var roomName = "ROOM_NAME";
var spaceMembers = ["SPACE_MEMBER_1@gmail.com", "SPACE_MEMBER_2@gmail.com"];
var space = {
displayName: roomName,
memberships: spaceMembers
};
var url = "https://chat.googleapis.com/v1/spaces?key=" + accessToken;
var options = {
"method": "POST",
"muteHttpExceptions": true,
"headers": {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
"Content-Type": "application/json"
},
"payload": JSON.stringify(space)
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response)
}
I defined the scopes and changed the project to be GCP And the response I get is:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"memberships\" at 'space': Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "space",
"description": "Invalid JSON payload received. Unknown name \"memberships\" at 'space': Cannot find field."
}
]
}
]
}
}
I couldn't figure out where the problem was I apologize if my question is not clear because of my bad english Thank you