#data.nextlink is not present in the securit graph API when trying t pull last set of data - python-3.x

While using security graph api in azure, when i reach the last set of data in the payload #data.nextlink is missing,so that i'm unable to fetch the next set of data?

I read the Graph api and Security Graph api carefully, and I found that when the current page data is fully loaded, there should be no #odata.nextlink parameter.
When you see my test results, I think this api design may need to be improved, when $top is equal to odata count.
Because all the data has been loaded, there is no next page of data you mentioned.
Sample
Query this api
I know that this api will return 63 data after access.
https://graph.microsoft.com/beta/security/secureScores?$top=63&$count=true
Result
Query #odata.nextLink.
When $top=63, although there is no data on the next page, there will still be the #odata.nextLink parameter.
When $top=64, we will see that the #odata.nextLink parameter is gone.

Related

Non-standard REST pagination approach in Data Factory?

I'm trying to figure out how to work with a REST api call that is paginated. The JSON response from each page of pagination has a flag "lastPage": True or "lastPage": False to specify if you've reached the last page.
In the Data Factory REST Connector article, the pagination section mentions several supported pagination schemes:
Absolute or relative path of next page in response body or header
Query parameter for the next page in response body or header
Header value for next page in response body or header
None of these three approaches seem to describe the type of response I'm dealing with. What solution would work in this case?
Here's the documentation for the API I'm working with.
About your request, it's not supported for now.
You could post the feedback here: https://feedback.azure.com/forums/270578-data-factory
We can help you vote it up to make product team know.

How can I paginate Pagerduty REST API results when requesting incident lists?

I'm building an application which pulls down incident listings for my org via Pagerduty's REST API.
The GET /incidents endpoint does respond with more, offset, and other keys that are indicative of pagination being supported, and it does make intuitive sense on this endpoint, but I haven't been able to actually paginate these results:
Passing offset or limit as a query param returns a 403
Passing these in various forms in request headers just gets ignored entirely
Is there a way to paginate these results at all?
it might help to include the code you're using to make the request, or a curl request from the command line. Including pagination parameters shouldn't lead to a 403, so I'm thinking something else might be missing.
You should be able to paginate the lists using GET parameters, e.g
https://api.pagerduty.com/incidents?limit=20&offset=100
limit has a maximum value of 100, and limit + offset together must be less than 10,000. That might be why you were getting an error?
See here for additional details on the pagination parameters
Yes, it's possible to paginate the results.
After invoking the API method for the first time, you need to check the more response field value. If true, then you can call the API method again with an updated offset.
offset is related to the total results, and not the total pages.
The 403 error code response you're getting is most likely related to the user permissions and not with paginating results.

how to set offset and limit while fetching records from chaincode in hyperledger fabric v 1.4 using nodejs chaincode?

I have more than 500 records in my blockchain network and i want to write a chaincode for the pagination on frontend. I have used getQueryResultWithPagination and getStateByRangeWithPagination but my concern is that i want to fetch records starting from 90th to 100th means 10 records but not starting from beginning neither i want to fetch the whole record. My chaincode is written in nodejs. I'm stuck on this and would really appreciate the community to give me their valuable suggestions.
Are you looking for directly jumping to a page if so, then its not possible. One drawback of the linked list style pagination is that you can’t pre-compute the rows for a particular page from the page number and the rows per page. Jumping to a specific page doesn’t really work.
Just see here for the reference: https://docs.couchdb.org/en/stable/ddocs/views/pagination.html
getQueryResultWithPagination of course only works with CouchDB ... so when using the CouchDB query language you should be able to specify the skip parameter in your actual query. Note that per the documentation, the limit parameter is not honored as the page size parameter is used:
If a pageSize is specified using the paginated query APIs (GetStateByRangeWithPagination(), GetStateByPartialCompositeKeyWithPagination(), and GetQueryResultWithPagination()), a set of results (bound by the pageSize) will be returned to the chaincode along with a bookmark. The bookmark can be returned from chaincode to invoking clients, which can use the bookmark in a follow on query to receive the next “page” of results.
Of course to build a front-end client which pages through results, you need to pass both the pageSize and bookmark parameters to getQueryResultWithPagination and your chain code function will need to return the bookmark to the caller so that it can be passed in to fetch the next page of results.

Azure Billing Usage API not returning additional properties

I am following this link to get my usage details for azure account. As per the official documentation, by using $expand=properties/additional properties should return additional properties (such as consumed service, cost center etc) in result set. However I am getting the same output irrespective of using expand in url.
URLs used are as below
Without expand :
https://management.azure.com/subscriptions/{subscriptionid}/providers/Microsoft.Consumption/usageDetails?api-version=2018-06-30&
With expand :
https://management.azure.com/subscriptions/{subscriptionid}/providers/Microsoft.Consumption/usageDetails?api-version=2018-06-30&$expand=properties/additionalProperties
Both the requests are returning same result set. Am I missing something here?
By default, the API only returns summarized usage information with a meter ID. If you want additional information on the meter, or additional information about the resource, you will need to add the expand parameter with the appropriate value:
Expanded meter information: properties/meterDetails
Expanded properties bag: properties/additionalProperties
You may try Sample Call for Additional Details:
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/usageDetails?api-version=2018-03-31&$expand=properties/additionalProperties
Please note that additionalProperties field will show up only when some additional data is available. For most cases, in general, there is no additional data. If some information is always expected to be available in additionalProperties, then it should be part of properties field in response and not the additionalProperties. additionalProperties is only for displaying some special/edge case information, which is not a candidate for a the main properties field.
The additionalProperties field will be present in response, if there are some additional info available to show, else it will be omitted to optimize the response payload size.
Try using this API this works for me:
https://management.azure.com/subscriptions/{Subsid}/providers/Microsoft.Billing/billingPeriods/202204/providers/Microsoft.Consumption/usageDetails?$expand=meterDetails,additionalProperties&metric=AmortizedCost&api-version=2019-05-01
Documentation

GitHub Search API only return 30 results

https://api.github.com/search/issues?q=stress+test+label:bug+language:python+state:closed
the above query is suppose to return 76 results, and when I try to run it, it only returns 30. I guess GitHub return results in portions when it is over 30. Any idea how I can get the rest of the results?
You need to use page parameter, e.g. for next 30 page = 2
https://api.github.com/search/issues?q=stress+test+label:bug+language:python+state:closed&page=2
You can also use per_page parameter to change the default size of 30. It supports max size of 100. Like this:
https://api.github.com/search/issues?q=stress+test+label:bug+language:python+state:closed&per_page=100
More detail can be found here
The Problem: Github api response doesn't contain all the relevant data.
Solution: The api from server is limiting the amount of items the user gets and splitting it into pages (pagination). You should explicitly Specify in your request how many items you'd like to receive from server pagination engine ,using formula for Github pagination api
?page=1&per_page=<numberOfItemsYouSpecify>"
For example: I'd like to get all my collaborators info in my private repo. I'm performing curl request to Github contains: username, authentication token , Organization and repository name and api call with pagination magic.
curl -u johnDoe:abc123$%^ https://api.github.com/repos/MyOrganizationName/MyAwesomeRepo/collaborators?page=1&per_page=1000"
Explanation:
What is Pagination: Pagination is the process of splitting the contents or a section of a website into discrete pages. Users tend to get lost when there's bunch of data and with pagination splitting they can concentrate on a particular amount of content. Hierarchy and paginated structure improve the readability score of the content. Loading pages is due to the less content on each item and each page has a separate URL which is easy to refer.
In this use case Github api splits the result into 30 items per resonse, depends on the request
Github reference:
Different API calls respond with different defaults. For example, a
call to List public repositories provides paginated items in sets of
30, whereas a call to the GitHub Search API provides items in sets of
100

Resources