[Matchmaker] BadRequest (21400)

When I try to call the “CreateTicketAsync” callback like in this example, I initialize the Unity Services and authenticate myself previously and Multiplay set up. What things I could miss? I set up the matchmaker in the Unity Dashboard. Do I have to do something else before calling “CreateTicketAsync”?

Unity: 2021.3.14f1
Multiplay: 1.0.0-pre.7
Matchmaker: 1.0.0-pre.14

Example Code:

private async Task CreateTicket()
        {
            var attributes = new Dictionary<string, object>();
            var players = new List<Player>
            {
                new(AuthenticationService.Instance.PlayerId)
            };
           
            // Set options for matchmaking
            var options = new CreateTicketOptions("MainWorld", attributes);
           
            // Create ticket
            var ticketResponse = await MatchmakerService.Instance.CreateTicketAsync(players, options);

            // Print the created ticket id
            Debug.LogFormat($"Created ticket with id: {ticketResponse.Id}");
        }

Errors:

[Matchmaker]: BadRequest (21400)
Title: Bad Request
Errors:
{"error":["No config found for upid 758efb56-0ce6-46cf-a4ff-ac1eff77c195 and env 4adef20a-8ca3-4acf-b7fc-43a2e817ac82"]}

UnityEngine.Logger:LogError (string,object)
Unity.Services.Matchmaker.Logger:LogError (object) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/Utils/Logger.cs:17)
Unity.Services.Matchmaker.WrappedMatchmakerService:ResolveErrorWrapping (Unity.Services.Matchmaker.MatchmakerExceptionReason,System.Exception) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:322)
Unity.Services.Matchmaker.WrappedMatchmakerService/<TryCatchRequest>d__14`2<Unity.Services.Matchmaker.Tickets.CreateTicketRequest, Unity.Services.Matchmaker.Models.CreateTicketResponse>:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:251)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Matchmaker.Response`1<Unity.Services.Matchmaker.Models.CreateTicketResponse>>:SetException (System.Exception)
Unity.Services.Matchmaker.Apis.Tickets.TicketsApiClient/<CreateTicketAsync>d__7:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Apis/TicketsApi.cs:122)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Matchmaker.Http.HttpClientResponse>:SetResult (Unity.Services.Matchmaker.Http.HttpClientResponse)
Unity.Services.Matchmaker.Http.HttpClient/<MakeRequestAsync>d__1:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/HttpClient.cs:41)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Matchmaker.Http.HttpClientResponse>:SetResult (Unity.Services.Matchmaker.Http.HttpClientResponse)
Unity.Services.Matchmaker.Http.HttpClient/<CreateWebRequestAsync>d__3:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/HttpClient.cs:56)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Matchmaker.Http.HttpClientResponse>:SetResult (Unity.Services.Matchmaker.Http.HttpClientResponse)
Unity.Services.Matchmaker.Http.HttpClient/<CreateHttpClientResponse>d__4:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/HttpClient.cs:84)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Matchmaker.Http.HttpClientResponse>:SetResult (Unity.Services.Matchmaker.Http.HttpClientResponse)
Unity.Services.Matchmaker.Http.HttpClient/<>c__DisplayClass4_0/<<CreateHttpClientResponse>b__0>d:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/HttpClient.cs:81)
System.Threading.Tasks.TaskCompletionSource`1<Unity.Services.Matchmaker.Http.HttpClientResponse>:SetResult (Unity.Services.Matchmaker.Http.HttpClientResponse)
Unity.Services.Matchmaker.Http.UnityWebRequestHelpers/<>c__DisplayClass0_0:<GetAwaiter>b__0 (UnityEngine.AsyncOperation) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/UnityWebRequestHelpers.cs:34)
UnityEngine.AsyncOperation:InvokeCompletionEvent ()
HttpException`1: (400) HTTP/1.1 400 Bad Request
Unity.Services.Matchmaker.Http.ResponseHandler.HandleAsyncResponse (Unity.Services.Matchmaker.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/ResponseHandler.cs:122)
Unity.Services.Matchmaker.Http.ResponseHandler.HandleAsyncResponse[T] (Unity.Services.Matchmaker.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/ResponseHandler.cs:226)
Unity.Services.Matchmaker.Apis.Tickets.TicketsApiClient.CreateTicketAsync (Unity.Services.Matchmaker.Tickets.CreateTicketRequest request, Unity.Services.Matchmaker.Configuration operationConfiguration) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Apis/TicketsApi.cs:121)
Unity.Services.Matchmaker.WrappedMatchmakerService.TryCatchRequest[TRequest,TReturn] (System.Func`3[T1,T2,TResult] func, TRequest request) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:228)
Rethrow as MatchmakerServiceException: HTTP/1.1 400 Bad Request
Unity.Services.Matchmaker.WrappedMatchmakerService.ResolveErrorWrapping (Unity.Services.Matchmaker.MatchmakerExceptionReason reason, System.Exception exception) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:328)
Unity.Services.Matchmaker.WrappedMatchmakerService.TryCatchRequest[TRequest,TReturn] (System.Func`3[T1,T2,TResult] func, TRequest request) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:251)
Unity.Services.Matchmaker.WrappedMatchmakerService.CreateTicketAsync (System.Collections.Generic.List`1[T] players, Unity.Services.Matchmaker.CreateTicketOptions options) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:55)
Asteroids_Host_Simple.Other.ApplicationController.CreateTicket () (at Assets/Asteroids-Host-Simple/Other/ApplicationController.cs:95)
Asteroids_Host_Simple.Other.ApplicationController.LaunchInMode (System.Boolean isServer, System.String profileName) (at Assets/Asteroids-Host-Simple/Other/ApplicationController.cs:76)
Asteroids_Host_Simple.Other.ApplicationController.Start () (at Assets/Asteroids-Host-Simple/Other/ApplicationController.cs:34)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) (at <d6232873609549b8a045fa15811a5bd3>:0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at <bae255e3e08e46f7bc2fbd23dde96338>:0)
UnityEngine.UnitySynchronizationContext.Exec () (at <bae255e3e08e46f7bc2fbd23dde96338>:0)
UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at <bae255e3e08e46f7bc2fbd23dde96338>:0)

Hi, thanks for your question. Are you still experiencing this issue? I can see in the last 24 hours that a couple of tickets were successfully created for your project and a Multiplay allocation was requested.

The steps you took sound right. The error would suggest that the matchmaker is unable to find the config that you set up through UDash. Is it possible that the matchmaker was set up for a different environment than the one you were trying to hit with this request?

1 Like

Thank you for your response.

Yes, luckily I solved the issue. There was 2 different environment one for Production and one for Development. When I looked at the URL while at Multiplayer Dashboard, I realised there were IDs that match this error. Then I deleted Development Environment so there is only one Environment left. And then it worked :slight_smile:

But I suggest that this error could be more human-friendly. Maybe the error can indicate explicitly that the problem is actually about a different environment setup

Well that’s not a proper solution. How can one change the environment the ticket is being created towards? I also have two environments where development is the only one properly setup. How can I tell MatchmakerService to create a ticket in that environment to avoid the error?

1 Like

@DeathPro

var options = new InitializationOptions();
options.SetEnvironmentName("dev");

await UnityServices.InitializeAsync(options);

This will help defining an environment beforehand. That’s what it fixed for me proplery

2 Likes

Yes, this will force the Player Auth SDK to fetch a token for the dev environment. By defaut the environment is set to Production

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Services.Authentication;
using Unity.Services.Matchmaker;
using Unity.Services.Matchmaker.Models;
using TMPro;
using System.Threading.Tasks;
using Unity.Netcode.Transports.UTP;
using Unity.Netcode;
using Unity.Services.Core;
using Unity.Services.Core.Environments;
public class TicketCreation : MonoBehaviour
{

[SerializeField] private TMP_Dropdown gameModeDropdown;

private string currentTicket;


private async void Start()
{
    if (Application.platform != RuntimePlatform.LinuxServer)
    {
        var options = new InitializationOptions();
        options.SetEnvironmentName("production");

        await UnityServices.InitializeAsync(options);
        await AuthenticationService.Instance.SignInAnonymouslyAsync();
    }
}
public async void ClientJoin()
{
    CreateTicketOptions createTicketOptions = new CreateTicketOptions("DefaultQueue",
        new Dictionary<string, object> { { "GameMode", gameModeDropdown.options[gameModeDropdown.value].text } });

    List<Player> players = new List<Player> { new Player(AuthenticationService.Instance.PlayerId) };

    CreateTicketResponse createTicketResponse = await MatchmakerService.Instance.CreateTicketAsync(players, createTicketOptions);
    currentTicket = createTicketResponse.Id;
    Debug.Log("Ticket created");

    while (true)
    {
        TicketStatusResponse ticketStatusResponse = await MatchmakerService.Instance.GetTicketAsync(createTicketResponse.Id);

        if (ticketStatusResponse.Type == typeof(MultiplayAssignment))
        {
            if (ticketStatusResponse.Type == typeof(MultiplayAssignment))
            {
                MultiplayAssignment multiplayAssignment = (MultiplayAssignment)ticketStatusResponse.Value;

                if (multiplayAssignment.Status == MultiplayAssignment.StatusOptions.Found)
                {
                    UnityTransport transport = NetworkManager.Singleton.GetComponent<UnityTransport>();
                    transport.SetConnectionData(multiplayAssignment.Ip, ushort.Parse(multiplayAssignment.Port.ToString()));
                    NetworkManager.Singleton.StartClient();

                    Debug.Log("Match Found");
                    return;
                }
                else if (multiplayAssignment.Status == MultiplayAssignment.StatusOptions.Timeout)
                {
                    Debug.Log("Match TimeOut");
                    return;
                }
                else if (multiplayAssignment.Status == MultiplayAssignment.StatusOptions.Failed)
                {
                    Debug.Log("Match failed: " + multiplayAssignment.Status + " " + multiplayAssignment.Message);
                    return;
                }
                else if (multiplayAssignment.Status == MultiplayAssignment.StatusOptions.InProgress)
                {
                    Debug.Log("Match is in progress");
                    return;
                }
            }

        }
        await Task.Delay(1000);
    }
}

}

Title: Bad Request

HttpException`1: (400) HTTP/1.1 400 Bad Request

when i try to create a ticket in my production evn .its getting error