REST API to export Accounts Report

Hi, I am trying to run either of the following below, worth noting I am using the long ID and not the short one.

https://tenant.api.identitynow.com/v3/accounts?filters=sourceId eq “sourceid 1”

https://tanant.api.identitynow.com/v3/accounts?filters=sourceId in (“sourceid 1”,“sourceid 2”)

When I do, I get the following error message:

{“detailCode”:“400.1 Bad request content”,“trackingId”:“b7b5b124cc454186a3982cdff7c8b1be”,“messages”:[{“locale”:“en-US”,“localeOrigin”:“DEFAULT”,“text”:“The request was syntactically correct but its content is semantically invalid.”},{“locale”:“en-US”,“localeOrigin”:“REQUEST”,“text”:“The request was syntactically correct but its content is semantically invalid.”}],“causes”:}

Hi Adrien,

I’m able to call both with no problems. Are you using Postman to invoke these endpoints, or another tool?

Postman and just using an Bearer token for now. Not sure what I am doing wrong and other commands work. Here is what I am running

Maybe my Source ID is wrong, but I pretty sure its correct.

I removed your image because your tenant was visible in the URL, but you attempted to block it out in other parts. I figured you didn’t want that to be visible. The only difference I noticed in your URL vs mine is the style of the double quotes around the sourceId. Did you copy/paste the sourceId with the quotes into Postman? If so, those quotes might be what is causing the 400. Try deleting those quotes and type them in directly in Postman. For reference, here is what mine looks like. Notice how your quotes have a curve, whereas mine are straight.

Hi Colin, yes appreciate it. I removed it on the second attempt. Let me try that now

It worked :grin: I knew it was stupid. Yes I copied and pasted it originally from another post on here! I have learnt my lesson. Literally made my day on this by the way! Thank you.

Following from this, what is the process to run past 250 limit? If I want to get the data for a source containing 1000 records, what do I need to run to ensure I capture all of it. I just realised I am not getting the full set.

You will need to paginate.

Yeah, I have read that part 50 times and don’t get it. Can you dumb it down for me and show me an example of what that would mean for the above. Does paginate = how many pages my source connection have? So if I have 7 Accounts tab pages then I repeat by that many?

I assume offset of 0-249 includes the headers and 1-250 doesnt include the headers. Does that I mean I have to run multiple commands of 1-250, followed by 250-500…etc Is that what it means.

Pagination is a mechanism to artificially limit how much data can be retrieved in a single API call so as to not overload the network. It prevents users from requesting several hundred megabytes (possibly gigabytes) of data in a single API call that will cause performance issues for others using the API.

To paginate a list of records, whether that be identities, accounts, sources, roles, etc. You will need to make several API calls, adjusting the offset in each call. To get all of the accounts in a source, you will need to make the following API calls:

  • Get records 0-249: GET https://{tenant}.api.identitynow.com/v3/accounts?filters=sourceId eq ‘2c9180835d2e5168015d32f890ca1581’
  • Get records 250-499: GET https://{tenant}.api.identitynow.com/v3/accounts?filters=sourceId eq ‘2c9180835d2e5168015d32f890ca1581’&offset=250
  • Get records 500-749: GET https://{tenant}.api.identitynow.com/v3/accounts?filters=sourceId eq ‘2c9180835d2e5168015d32f890ca1581’&offset=500
  • Keep adding 250 to your offset until you don’t get any records in the response.

Usually this is accomplished via some scripting language, like Python, PowerShell, etc.

2 Likes

Amazing, thank you. I will see if I can learn some Python or Powershell or both to make this happen.

Much appreciated for the quick response. Will try it shortly.