March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I have working code for retrieving data from Sophos Central. I have added pagination for other data sources before but can't get it working with Sophos.
Here is my code:
SophosBearerToken = "Bearer " & (Json.Document(Web.Contents("https://id.sophos.com/api/v2/oauth2/token",
[
Headers = [#"Content-Type"="application/x-www-form-urlencoded"],
Content = Text.ToBinary("grant_type=client_credentials&client_id=" & #"SophosClientID" & "&client_secret=" & #"SophosClientSecret" & "&scope=token")
]
)) [access_token]),
url="https://api-us03.central.sophos.com/endpoint/v1/endpoints",
Header=[
#"Authorization"=#"SophosBearerToken",
#"x-tenant-id"= tenantID
],
PartnerIDQuery = Json.Document(Web.Contents(url,
[Headers=Header])),
items = PartnerIDQuery[items]
Can anybody help with this?
Hi @v-yingjl ,
the first reference is the same issue that I have and appears to be unresolved.
There isn't an error message. However if I put page=1 into the url as per the sophos documentation, I receive the same items as when I put page=3 or page=5 etc
Still no success retrieving all the items for a sophos API. Has anybody succeeded in creating an api call to Sophos that retrieves all the items?
In case it helps, here is a video that shows a different way to get your data potentially without pagination (just offset).
Power BI - Tales From The Front - REST APIs - YouTube
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thanks.
From the Sophos APi documentation:
PAGE BY OFFSET
When paging by offset, the client asks for the specific page of data they want, starting from Page 1. The query parameters that affect paging are:
page, pageSize [Integer]
pageTotal [Boolean]
The pages field in the response will have the following sub-fields:
current [Integer] The 1-based page number being returned
size [Integer] Same as the pageSize query parameter passed in.
total [Integer] The total number of pages that exist
All query parameters are optional. By default, if you don't specify a query parameter, the first page with up to 50 items on it is returned. The number of pages isn't returned.PAGE BY KEY
When paging by key, the client asks for a page worth of data after a particular matching key. You can omit this key to fetch the first page. The query parameters are the same.
The pages field in the response will have the following sub-fields:
fromKey [String] The key of the first item in the array of items returned
nextKey [String] The key to use as the value of the pageFromKey query parameter when fetching the next page of data. This field won't present if there are no more pages to fetch.
size [Integer] Same as the pageSize query parameter passed in or its default value.
total [Integer] (Optional) the total number of pages that exist, if pageTotal=true was passed into the request.
maxSize [Integer]
All query parameters are optional. By default, if you don't specify a query parameter, the first page with up to 50 items on it is returned. The number of pages isn't returned.
Hi @ShaunBuchan
How does the API specify that pagination works? Are you accessing pages by number, by using a text string in the URL, by cursor?
Let's say that you are accessing different pages specified by a list called pages
You can use a query like this that uses List.Transform to make a Web.Contents request for each item in the list
pages = {"sales", "marketing","hr"},
url="https://api-us03.central.sophos.com/endpoint/v1/endpoints/",
Header=[
#"Authorization"=#"SophosBearerToken",
#"x-tenant-id"= tenantID
],
PartnerIDQuery = List.Transform(pages, each Json.Document(Web.Contents(url & _ , [Headers=Header])))
I'm using strings here as I don't actually know how the API works. If you can supply details I can modify this for you.
Regards
Phil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.
Proud to be a Super User!
Hi @ShaunBuchan ,
Have you got any error message when you run the query and could you share the error message?
You can also refer this simliar issue:
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
16 | |
13 | |
13 | |
9 |
User | Count |
---|---|
36 | |
31 | |
20 | |
19 | |
17 |