.net sdk JobClient BulkImportUsers is broken

The wired thing is it works last night.

Hi @ernestzhang17,

Welcome to the Auth0 Community!

We are seeing a bug that is causing this. A solution should be rolled out early next week. Follow this thread for details:

edit: this is not the issue, see the rest of this thread for more details.

1 Like

Thanks for your reply.

It looks like a different issue to me. My import file is very small about 1kb. I looked at the Http request payload the SDK send out. Some headers in the payload need to be added or remove to make the request pass the validation.

–399d6177-c83d-4fef-b361-26482a52edc9
Content-Type: text/plain; charset=utf-8 -------------- need to be removed
Content-Disposition: form-data; name=connection_id

con_9lS2p7m4c7la9agB
–399d6177-c83d-4fef-b361-26482a52edc9
Content-Type: text/plain; charset=utf-8 -------------- need to be removed
Content-Disposition: form-data; name=upsert

true
–399d6177-c83d-4fef-b361-26482a52edc9
Content-Type: application/json -------- need to be added
Content-Disposition: form-data; name=users; filename=users.json; filename*=utf-8’'users.json

There must be a multipart- form headers validation logic change happened on the API side recently, which breaks the SDK.

I have to manually remove the Content-Type header for “connection_id”, “upsert” parameters, and add ”Content-Type: application/json” for “users” parameter to make it work.

 **var httpClient = new HttpClient();**
**                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", CoreService.Token);**
**                var idParam = new StringContent(connectionId);**
**                var upSertParam = new StringContent("true");**
**                var byteParam = new ByteArrayContent(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(usersToImport)));**

**                idParam.Headers.Remove("Content-Type");**
**                upSertParam.Headers.Remove("Content-Type");**
**                byteParam.Headers.ContentType = new MediaTypeHeaderValue("application/json");**

**                var formContent = new MultipartFormDataContent()**
**                {**

**                    { idParam, "connection_id" },**
**                    { upSertParam, "upsert" },**
**                    { byteParam, "users", "users.json" }**
**                };**
**   var response = await httpClient.PostAsync(new Uri($"https://{CoreService.SelectedTenant.Name}/api/v2/jobs/users-imports"), formContent);**
**                response.EnsureSuccessStatusCode();**

Thanks for the added info. It sounds like your issue is related to how the SDK is creating the request. Can you please share the name and version of the SDK and environment you are using?

Sure.


It’s a .net framework WPF application. I tried both 7.14 and 7.15 SDK.

usersToImport is a List of users to import.

     using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(usersToImport))))
            {
                var job = await client.Jobs.ImportUsersAsync(connectionId, "users.json", stream, true, "user.json", false);

}

That’s how I created the request. Like I said it works a couple days ago. Not sure what makes a difference.

Are you using this SDK GitHub - auth0/auth0.net: .NET client for the Auth0 Authentication & Management APIs.? It doesn’t look like there is a version 7.15.

Could you please provide an example user or confirm that they are complying with the required schema?

[

  {

    "user_id": "cd49bc59-6baf-45d6-9746-3fe90df661eb",

    "email": "kgra@gmail.com",

    "email_verified": false,

    "given_name": "xxxxx",

    "family_name": "xxx",

    "name": "kxxx xxxx",

    "nickname": "kgrandpak",

    "user_metadata": {

     

    },

    "blocked": false,

    "mobile": "+1 555253543",

    "phone": [

      "+1 555253543"

    ],

    "custom_password_hash": {

      "algorithm": "pbkdf2",

      "hash": {

        "value": "$pbkdf2-sha256$i=10000,l=32$mysalt$myhash",

        "encoding": "utf8"

      }

    }

  }

]

This a very simple one(credential info deleted), I can import it from the Dashboard API page.


About the 7.15 version, it exists on Nuget. I do notice that it doesn’t exist on the GitHub page you provided. So I downgrade it to 7.14 and the problem still exists. That’s why I suspect there is a API side change.

Thanks for the additional info. I see the release now on the GH repo, so that makes sense. I also think I may have tracked down the issue and created a bug report with the team. I’ll update here when I have a response from them.

Thanks for your patience!

1 Like

Hey all, this should be resolved now. Please open a new topic if you have any other issues.