File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ request_adapter = GraphRequestAdapter(auth_provider)
101101client = GraphServiceClient(request_adapter)
102102
103103async def get_user ():
104- user = await client.users_by_id (' userPrincipalName' ).get()
104+ user = await client.users.by_user_id (' userPrincipalName' ).get()
105105 print (user.display_name)
106106
107107asyncio.run(get_user())
@@ -133,11 +133,12 @@ asyncio.run(me())
133133
134134Failed requests raise ` APIError ` exceptions. You can handle these exceptions using ` try ` ` catch ` statements.
135135``` py
136+ from kiota_abstractions.api_error import APIError
136137async def get_user ():
137138 try :
138- user = await client.users_by_id (' userID' ).get()
139+ user = await client.users.by_user_id (' userID' ).get()
139140 print (user.user_principal_name, user.display_name, user.id)
140- except Exception as e:
141+ except APIError as e:
141142 print (f ' Error: { e.error.message} ' )
142143
143144asyncio.run(get_user())
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ This package (`msgraph-sdk`) will only contain models that match the [Microsoft
3434resp = client.get(' /users/userId/messages' )
3535
3636# msgraph-sdk
37- req = client.users_by_id (' userId' ).messages() .get()
37+ req = client.users.by_user_id (' userId' ).messages.get()
3838resp = asyncio.run(req)
3939```
4040
@@ -120,7 +120,7 @@ request_config = MessagesRequestBuilder.MessagesRequestBuilderGetRequestConfigur
120120 query_parameters = query_params,
121121)
122122
123- messages = asyncio.run(client.users_by_id (' userId' ).messages() .get(request_configuration = request_config))
123+ messages = asyncio.run(client.users.by_user_id (' userId' ).messages.get(request_configuration = request_config))
124124for msg in messages.value:
125125 print (msg.subject)
126126```
@@ -129,15 +129,15 @@ See [the examples](docs/Examples.md) on how to pass headers in your requests.
129129
130130## Exception handling
131131
132- Any ` 4xx ` or ` 5xx ` responses from the Graph API will result in an ` ApiException ` being thrown.
132+ Any ` 4xx ` or ` 5xx ` responses from the Graph API will result in an ` APIError ` being thrown.
133133
134134``` py
135-
135+ from kiota_abstractions.api_error import APIError
136136try :
137137 users = asyncio.run(client.users().get())
138138
139- except ApiException as e {
140- return f " Exception occurred: { repr (e) } "
139+ except APIError as e {
140+ return f " Exception occurred: { e.error.message } "
141141}
142142```
143143## Dependency changes
You can’t perform that action at this time.
0 commit comments