Hi,
This is somewhat related to this post I created LobbyService (401) HTTP/1.1 401 Unauthorized on Multiplay Dedicated Server.
I tried creating the Lobby with the REST API instead and I get the following error
Lobby creation failed: {
code: 16000,
detail: 'request failed validation',
details: [
{
errorType: 'validation',
message: "missing serviceId in 'service-id' header"
}
],
status: 400,
title: 'Bad Request',
type: 'http://unity3d/lobby/errors/validation-error'
}
That the function I use to create the Lobby
router.post('/createlobby', async function (req, res) {
try {
const unformattedOptions = req.body;
const options = {
"name": req.query.name,
"maxPlayers": 4,
"isPrivate": null,
"isLocked": null,
"player": {
"id": unformattedOptions["Player"].id
},
"password": null,
"data": {}
};
const accessToken = await GetStatelessToken();
const url = "https://lobby.services.api.unity.com/v1/create";
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken.accessToken}`,
},
body: JSON.stringify(options)
});
if (!response.ok) {
const errorDetails = await response.json();
console.error("Lobby creation failed:", errorDetails);
res.status(400).send(errorDetails);
return;
}
const lobbyResult = await response.json();
console.log("Lobby created successfully:", lobbyResult);
res.send(lobbyResult);
}
catch (error) {
console.error('Request Failed:', error);
}
});
I’m quite certain my GetStatelessToken function works well. I have no issue using it with Cloudsave or Matchmaker. I tried creating the Lobby on the client side, there was no issue.
I could not find any information about the above error, any help would be much appreciated. It’s not clear if the issue is from the HTTP request header or from the authorization token.
EDIT: the data I’m passing the the boddy of the request
{"name":"Test","maxPlayers":4,"isPrivate":null,"isLocked":null,"player":{"id":"USERID"},"password":null,"data":{}}
I checked the USERID in the print to compare it to the Cloudsave entry and it matches.