Legacy Dev Forum Posts

 View Only

Sign Up

Getting all users with assigned stations

  • 1.  Getting all users with assigned stations

    Posted 06-05-2025 18:05

    pierrick | 2017-01-30 14:10:05 UTC | #1

    I need to retrieve the list of users with assigned stations. I noticed 2 things:

    • when I call the UsersApi GetUsers() method, the user's station field is always null
    • So I used the UsersApi GetUserIdStation(user.id) instead but I hit the 409 (too many requests) pretty quickly since there are 100s of users in the org I connect to

    So, 2 questions:

    • Is this expected that the user's station field should be null? Is it a bug?
    • Should I slow down the number of requests to not hit the API limit?

    pierrick | 2017-01-30 14:14:08 UTC | #2

    Here is a sample code:

    <img src="//inin-prod-use1-developerforum.s3.amazonaws.com/original/1X/c90c976d65708af179bd5ae9417becdc98d6cf7f.jpg" width="532" height="353">

    And a screenshot showing the user's station as null:

    <img src="//inin-prod-use1-developerforum.s3.amazonaws.com/original/1X/e04293c9baddcc99e0ae54f0f2d7f6352d06b64d.jpg" width="492" height="255">

    However, when calling GetUserIdStation(), it does retrieve a station:

    <img src="//inin-prod-use1-developerforum.s3.amazonaws.com/original/1X/542870348e514e4e4b73807b1ba6375dd329495a.jpg" width="523" height="207">


    RogierBosch | 2017-01-31 07:31:23 UTC | #3

    Try /api/v2/stations station "status": "ASSOCIATED" then here is also an userID


    tim.smith | 2017-01-31 16:09:23 UTC | #4

    Per the docs for GET /api/v2/users, send expand=station to have the station information returned with the user objects.


    pierrick | 2017-01-31 16:24:45 UTC | #5

    I didn't see that before. Thanks!


    tim.smith | 2017-01-31 16:42:06 UTC | #6

    pierrick, post:1, topic:866
    Should I slow down the number of requests to not hit the API limit?

    Just wanted to answer this in case anyone finds it in the future.

    It's up to you how you want to handle rate limiting. You can either:

    • make requests unthrottled and once you get rate limited (409 response), wait for the number of seconds specified in the rate limiting headers before making addtional requests
    • do some math with the data in the rate limit headers to throttle your requests so you don't exceed the rate limit

    Personally, I use the first approach as it's easier to implement. We have rate limiting in place to stop you before you hurt anything, so hitting the rate limit isn't necessarially a bad thing. But if you are hitting it, it's a good idea to see if there's a better way to do what you're doing (exactly like you did with this post). More often than not, getting rate limited means you're doing something inefficiently.


    system | 2017-08-28 19:31:44 UTC | #7


    This post was migrated from the old Developer Forum.

    ref: 866