0

I'm getting the below Payload validation error while creating an Auth0 user:

Payload validation error: 'Additional properties not allowed: $type (consider storing them in app_metadata or user_metadata. See "Users Metadata" in https://auth0.com/docs/api/v2/changes for more details)'.

Here is the payload that I am sending (redacted irrelevant information):

img

This is how I am making the call:

//Calling to Get the token, working fine!
var managementApiClient = new ManagementApiClient(await GetAccessTokenAsync(), _config.Domain);

// create the user in Auth0
var result = await apiRetryPolicy.ExecuteAsync(
    async () =>
        await managementApiClient.Users.CreateAsync(userCreateRequest)
);


return result;

The client is written in C#, and .Net Core - the main thing that I couldn't find anywhere related to this is I am sending type within the input parameters.

Skully
  • 2,882
  • 3
  • 20
  • 31
user2948533
  • 1,143
  • 3
  • 13
  • 32
  • No answers yet! Any guidance will be helpful! Thanks in advance! – user2948533 Nov 16 '21 at 03:21
  • I have followed this thread:https://stackoverflow.com/Questions/627356/how-to-not-serialize-the-type-property-on-json-objects, and tried all the options, including changing the parameter from existing type to break it in individual params, but no luck - getting the same exception. Basically the CreateAsync() is serializing my object and introducing $type.So the problem is very clear, need to found how to ensure it does not do so. – user2948533 Nov 17 '21 at 07:56
  • which version of .net core are you using? – Shaker Kamal Nov 22 '21 at 11:04
  • Is it possible, that your Json settings generates `$type` property? – Demetrius Axenowski Nov 22 '21 at 16:51

2 Answers2

0

Auth0 used Json.NET for serialization objects. We can see in the Auth0 GitHub repository (HttpClientManagementConnection class).

And Auth0 serialization settings looks fine. But Serializer generated $type property for some reasons.

For generating of $type property Json.NET used TypeNameHandling serialization settings.

It seems your JSON serialization settings were redefined. Try to use global JSON DefaultSettings and setup TypeNameHandling property globally to None.

Alexander I.
  • 2,380
  • 3
  • 17
  • 42
0

When sending the headers, make sure they are correct, the -d options will default to sending a content type of application/x-www-form-urlencoded

In the end you want to be sending over JSON. And, you should be also sending an additional header: -H "Content-Type: application/json"

Before returning your result double check its in JSON format, this might help you from Auth0 Site

Transformer
  • 6,963
  • 2
  • 26
  • 52