microsoftgraph / microsoftgraph/msgraph-sdk-python
skiptoken for large request responses
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 630
- Fork
- 96
- Merge trung bình
- 15 giờ 20 phút
- Pull request đã merge (30 ngày)
- 3
Mô tả
I am looking to use the msgraph sdk for python. I want to get a list of devices in our tenant. We have thousands of devices. When using the msgraph.devices.get(), it will return 100 devices (the default limit for msgraph). Utilize the request_query=DevicesRequestBuilder.DevicesRequestBuilderGetQueryParameters(top=100,skip=100)
gives me this error msgraph.generated.models.o_data_errors.o_data_error.ODataError
After some digging in the Microsoft graph explorer for https://graph.microsoft.com/v1.0/devices?$top=100&$skip=100 gives this error
{
"error": {
"code": "Request_BadRequest",
"message": "'$skip' is not supported by the service.",
"innerError": {
"date": "2023-04-24T23:08:17",
"request-id": "e077ef6b-d848-4fba-8cce-257e7188a6ec",
"client-request-id": "4a9beda2-c3ee-0c9f-f012-5308f25f8954"
}
}
}
So, skip is not supported for devices. It is the same in the beta requests.
Since I am able to get the data_data_next_link from my initial devices.get() response, I tried
request_query=DevicesRequestBuilder.DevicesRequestBuilderGetQueryParameters(top=100,skiptoken='RNFw.....')
However, I get an error TypeError: __init__() got an unexpected keyword argument skiptoken
After digging through the code, I modified device_request_builder.py, changing the DevicesRequestBuilderGetQueryParameters(): adding
if original_name == "skiptoken":
return "%24skiptoken
......
skiptoken: Optional[str] = None
and class DevicesRequestBuilder(): modifying
self.url_template: str = "{+baseurl}/devices{?%24top,%24skip,%24search,%24filter,%24count,%24orderby,%24select,%24expand,%24skiptoken}
These make the skiptoken available and work with GetQueryParameters.
So basically modifying this module to work with the limitations of msgraph
Is there another way to accomplish paging with devices in this python module?
If not, I can try a pull request for this.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với device_request_builder.py và lớp DevicesRequestBuilderGetQueryParameters, sau đó so sánh request được tạo với data_data_next_link của response devices. Xác minh cách skiptoken được biểu diễn trong URL của request và liệu đường dẫn GetQueryParameters hiện có có thể theo nó hay không. Hoàn tất khi phân trang device có thể sử dụng next link hoặc skiptoken được trả về mà không gặp lỗi constructor đã nêu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- api
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 38/100