FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    Import Users; don't error on the existing ones

    Scheduled Pinned Locked Moved
    Q&A
    api import users
    0
    2
    2.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      casper
      last edited by

      I'm relative new to FusionAuth but it's quite a good system so far. Only I can't seem to do is import users correctly with my current setup. The setup is that I don't know from an N amount of import files which are all ready in imported. So it could be when I call
      Import users that the email and/or username is all ready present and the whole import is canceled. This is now ideal for me, I really would like to just skip the ones that are already present.

      Does anyone have an idea to do this? Would it make sense to first query the API to know which of the usernames and e-mails are present.

      1 Reply Last reply Reply Quote 0
      • joshuaJ
        joshua
        last edited by

        Hi @casper!

        Welcome to the community. This is working as designed. The import API is currently designed to only write new records to the database and not check if the record is already duplicated. This is partly for performance reasons. It maybe be possible to write a script to check existing records, and then only import "new" users based on that feedback, but we do not have any current documented cases of this.

        There is an option to get additional information about what is failing on your import.
        https://fusionauth.io/docs/v1/tech/apis/users/#import-users

        validateDbConstraints [Boolean] OPTIONAL Defaults to false
        Set this value to true in order to perform additional validation of the request.
        
        The import request is intended to be used to populate the initial set of users, this means FusionAuth does not expect to find duplicate users in the database. If a duplicate is encountered a 500 will be returned without this additional validation.
        
        If you intend to use this API with existing users in FusionAuth set this value to true to request additional validation be performed on the input request and a 400 response will be returned with JSON body indicating the duplicate values encountered.
        
        Setting this value to true will dramatically decrease the performance of this request. If importing large numbers of users in a single request you may need to increase request timeouts to ensure this request does not timeout before it has completed.
        
        

        I hope this helps,
        Josh

        1 Reply Last reply Reply Quote 0
        • First post
          Last post