Unable to create a registration using the .NET core client

  • Hiya,

    I'm unable to create a user registration using the .NET client libraries: https://fusionauth.io/docs/v1/tech/client-libraries/netcore

    I have verified that the API key is basically a super user. I've verified that I'm sending the registration object. I've tried twiddling different properties (verified, insertInstant) and made sure that the application exists. I've added the a user registration to the application manually and it works. Creating a user and setting the userdata works just fine. It just seems like the registration isn't working.

    I looked in https://github.com/FusionAuth/fusionauth-netcore-client/issues and https://github.com/FusionAuth/fusionauth-issues/issues but didn't see any relevant issues.

    Here's my code so far (you can run it with fusionauth_api_key=<key> dotnet.exe run -- foo@foo5.com bluepass123 blue)

    $ cat usermanager.csproj
    <Project Sdk="Microsoft.NET.Sdk">
        <PackageReference Include="FusionAuth.Client" Version="1.15.7" />
        <PackageReference Include="JSON.Net" Version="1.0.18" />
    $ cat Program.cs
    using System;
    using io.fusionauth;
    using io.fusionauth.domain;
    using io.fusionauth.domain.api;
    using System.Collections.Generic;
    using Newtonsoft.Json;
    namespace usermanager
        class Program
            private static readonly string apiKey = Environment.GetEnvironmentVariable("fusionauth_api_key");
            private static readonly string fusionauthURL = "http://localhost:9011";
            private static readonly string tenantId = "66636432-3932-3836-6630-656464383862";
            static void Main(string[] args)
                if (args.Length != 3) {
                    Console.WriteLine("Please provide email, password and favorite color.");
                string email= args[0];
                string password = args[1];
                string favoriteColor = args[2];
                FusionAuthSyncClient client = new FusionAuthSyncClient(apiKey, fusionauthURL, tenantId);
                User userToCreate = new User();
                userToCreate.email = email;
                userToCreate.password = password;
                Dictionary<string, object> data = new Dictionary<string, object>();
                data.Add("favoriteColor", favoriteColor);
                userToCreate.data = data;
                UserRegistration registration = new UserRegistration();
                registration.applicationId = Guid.Parse("4243b56f-0b45-4882-aa23-ac75eea22d22");
                registration.verified = true;
                registration.insertInstant = DateTimeOffset.UtcNow;
                var registrations = new List<UserRegistration>();
                userToCreate.registrations = registrations;
                UserRequest userRequest = new UserRequest();
                userRequest.sendSetPasswordEmail = false;
                userRequest.user = userToCreate;
                string u = JsonConvert.SerializeObject(userRequest);
                var response = client.CreateUser(null, userRequest);
                string json = JsonConvert.SerializeObject(response);
                if (response.WasSuccessful())
                    var user = response.successResponse.user;
                    Console.WriteLine("retrieved user with email: "+user.email);
                else if (response.statusCode != 200)
                    var statusCode = response.statusCode;
                    Console.WriteLine("failed with status "+statusCode);

  • Here's the JSON output of the response:


  • The User API will not create a registration, the registration portion of your request object is being ignored.

    If you review the User API, you will notice that the registration is not part of the request body.

    You can optionally create the user and then create a registration separately.

    We do offer a combo API that allows you to create a User and a User Registration in one go. To use this strategy, use the Combo version of the User Registration API.



  • @robotdan Ah, I missed that. I was looking at the response section, which had the registration. Thanks!

Looks like your connection to FusionAuth Forum was lost, please wait while we try to reconnect.