@ulrik_sandgren
This sounds very much like this thread: https://community.canvaslms.com/ideas/15924-course-creation-api-should-only-return-a-new-course-id-i...
In that thread, it was the courses that were not being created, even though a course ID was getting returned and everything was successful.
That doesn't necessarily explain why Canvas cannot find something after saying it was created, just conjecture on my part about there being a heavy load. I don't agree that the request was the right one, because eventually it seems that the course was being created, it just wasn't available immediately.
I send all my stuff through a SIS import where I expect that it will run in the background and may take some time. Maybe the expectation that it exist immediately is unrealistic and there is additional background processing that needs done? Still, it seems that Canvas may have made some changes that are affecting this as I had not seen anyone complain about this until just recently.
I don't know if your code was an effort to track down the problem or it was what was actually happening when you first noticed the problem. Normally, I wouldn't think people would verify that user existed when the previous API call said that it did -- not until I saw the other thread that is.
I see you're using the search API and basing it off the login ID. That gives me ideas of two things to consider (I don't know that either is the reason, just things to explore more).
- Maybe the user has been created in the user table when the API call returns but then additional processing happens for adding the login information.
- You are using the search capability and I think those are cached. If you had done a search for the user to see if it was there, then added it when it wasn't, and then searched to see if it was there, it might be returning the cached version where the user wasn't there.
What happens if you try to access to user directly rather than by using the search feature? When you create the user, you get an ID back that you can use directly rather than by searching by their login ID. If 914 is the userID, then you could should use GET /api/v1/users/914 instead of GET /api/v1/accounts/self/users/?search_term=xxxyyy@umu.se
It took my system 1205.69 ms to search for my email address and about half that much time to use my user ID or my sis_user_id. The more I searched, the quicker it got (going back to the caching issue), eventually settling in on about 300 ms [and the search_term never got much faster than 850 ms]. If you don't save the user ID returned from the create user command, you could use GET /api/v1/users/sis_user_id:zz