File tree Expand file tree Collapse file tree 4 files changed +12
-29
lines changed Expand file tree Collapse file tree 4 files changed +12
-29
lines changed Original file line number Diff line number Diff line change 1616
1717from msgraph_core .requests .batch_request_content import BatchRequestContent
1818from msgraph_core .requests .batch_request_content_collection import BatchRequestContentCollection
19- from msgraph_core .requests .batch_request_builder import BatchRequestBuilder
2019# Create a client
2120# code to create graph client
2221
23- user_client = GraphServiceClient (credentials = token , scopes = graph_scopes )
22+ graph_client = GraphServiceClient (credentials = token , scopes = graph_scopes )
2423
2524# Create a request adapter from the client
26- request_adapter = user_client .request_adapter
27-
28- # Create an instance of BatchRequestBuilder
29- batch_request_builder = BatchRequestBuilder (request_adapter )
25+ request_adapter = graph_client .request_adapter
3026
3127# Create some BatchRequestItems
3228
8682# post a collection
8783async def main ():
8884
89- batch_response_content = await client .batch .post (batch_request_content = collection )
85+ batch_response_content = await graph_client .batch .post (batch_request_content = collection )
9086 responses = batch_response_content .get_responses ()
9187 for item in responses :
9288 for item_body in item .responses :
Original file line number Diff line number Diff line change 1616
1717from msgraph_core .requests .batch_response_content import BatchResponseContent
1818from msgraph_core .requests .batch_response_content_collection import BatchResponseContentCollection
19- from msgraph_core .requests .batch_request_builder import BatchRequestBuilder
2019
2120# Create a client
2221# code to create a graph client
23- user_client = GraphServiceClient (credentials = token , scopes = graph_scopes )
22+ graph_client = GraphServiceClient (credentials = token , scopes = graph_scopes )
2423
2524# Create a request adapter from the clinet
26- request_adapter = user_client .request_adapter
27-
28- # Create an instance of BatchRequestBuilder
29- batch_request_builder = BatchRequestBuilder (request_adapter )
25+ request_adapter = graph_client .request_adapter
3026
3127# Create batch Items
3228request_info1 = RequestInformation ()
5551
5652
5753async def main ():
58- batch_response_content = await client .batch .post (batch_request_content = batch_content )
54+ batch_response_content = await graph_client .batch .post (batch_request_content = batch_content )
5955
6056 # Print the batch response content
6157 print (f"Batch Response Content: { batch_response_content .responses } " )
Original file line number Diff line number Diff line change 1919from msgraph_core .requests .batch_request_content import BatchRequestContent
2020
2121from msgraph_core .requests .batch_response_content import BatchResponseContent
22- from msgraph_core .requests .batch_request_builder import BatchRequestBuilder
2322# create client
2423# code to create client
25- user_client = GraphServiceClient (credentials = token , scopes = graph_scopes )
24+ graph_client = GraphServiceClient (credentials = token , scopes = graph_scopes )
2625
2726
2827# Create an Error map Parsable or import it from wherever you have it
@@ -41,10 +40,7 @@ def not_found() -> 'CustomError':
4140
4241
4342# Create a request adapter from client
44- request_adapter = user_client .request_adapter
45-
46- # Create an instance of BatchRequestBuilder
47- batch_request_builder = BatchRequestBuilder (request_adapter )
43+ request_adapter = graph_client .request_adapter
4844
4945# Create batch Items
5046request_info1 = RequestInformation ()
@@ -86,7 +82,7 @@ def not_found() -> 'CustomError':
8682async def main ():
8783 error_map = {"400" : CustomError , "404" : CustomError .not_found }
8884
89- batch_response_content = await client .batch .post (
85+ batch_response_content = await graph_client .batch .post (
9086 batch_request_content = batch_content , error_map = error_map
9187 )
9288
Original file line number Diff line number Diff line change 1414from msgraph_core .requests .batch_request_item import BatchRequestItem
1515from msgraph_core .requests .batch_request_content import BatchRequestContent
1616
17- from msgraph_core .requests .batch_request_builder import BatchRequestBuilder
18-
1917# import User model to serialize to
2018from msgraph .generated .models .user import User
2119# Create a client
2220# code to create graph client
23- user_client = GraphServiceClient (credentials = token , scopes = graph_scopes )
21+ graph_client = GraphServiceClient (credentials = token , scopes = graph_scopes )
2422
2523print (f"Graph Scopes: { graph_scopes } " )
2624
2725# Create a request adapter from the client
28- request_adapter = user_client .request_adapter
29-
30- # Create an instance of BatchRequestBuilder
31- batch_request_builder = BatchRequestBuilder (request_adapter )
26+ request_adapter = graph_client .request_adapter
3227
3328# Create batch Items
3429request_info1 = RequestInformation ()
5954
6055# Function to demonstrate the usage of BatchRequestBuilder
6156async def main ():
62- batch_response_content = await client .batch .post (batch_request_content = batch_content )
57+ batch_response_content = await graph_client .batch .post (batch_request_content = batch_content )
6358 # response_type=User
6459
6560 try :
You can’t perform that action at this time.
0 commit comments