Skip to content

Commit c77745b

Browse files
authored
Merge pull request #1756 from microsoftgraph/dev
Release 5.3.0
2 parents df8a643 + 9232733 commit c77745b

180 files changed

Lines changed: 6431 additions & 303 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/validatePullRequest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
env:
1414
solutionName: Microsoft.Graph.sln
1515
steps:
16-
- uses: actions/checkout@v3.3.0
16+
- uses: actions/checkout@v3.4.0
1717
- name: Setup .NET
1818
uses: actions/setup-dotnet@v3.0.3
1919
with:

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ and this project does adheres to [Semantic Versioning](https://semver.org/spec/v
88
## [Unreleased]
99

1010

11+
## [5.3.0] - 2023-03-21
12+
13+
### Added
14+
15+
- Allows checking for status codes without parsing request bodies in batch requests (https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/pull/626)
16+
- Updates kiota abstraction library dependencies to fix serialization errors.
17+
- Metadata fixes for missing expand clauses for messages,calendar and mailfolder endpoints
18+
- Latest metadata updates from 21st March 2023
19+
1120
## [5.2.0] - 2023-03-14
1221

1322
### Added

docs/errors.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,44 @@
11
Handling errors in the Microsoft Graph .NET Client Library
22
=====
33

4-
Errors in the Microsoft Graph .NET Client Library behave like errors returned from the Microsoft Graph service. You can read more about them [here](https://graph.microsoft.io/en-us/docs/overview/errors).
4+
Errors in the Microsoft Graph .NET Client Library behave like errors returned from the Microsoft Graph service. You can read more about them [here](https://learn.microsoft.com/en-us/graph/errors).
55

6-
Anytime you make a request against the service there is the potential for an error. In the case of an error, the request will throw a `ServiceException` object with an inner `Error` object that contains the service error details.
6+
Anytime you make a request against the service there is the potential for an error. In the case of an error, the request will throw a `ODataError` exception that contains the service error details and can be handled as below.
77

8-
## Checking the error
8+
```cs
9+
try
10+
{
11+
await graphServiceClient.Me.PatchAsync(user);
12+
}
13+
catch (ODataError odataError)
14+
{
15+
Console.WriteLine(odataError.Error?.Code);
16+
Console.WriteLine(odataError.Error?.Message);
17+
throw;
18+
}
19+
```
20+
21+
22+
## Checking the error status code
923

10-
There are a few different types of errors that can occur during a network call. These error codes are defined in [GraphErrorCode.cs](../src/Microsoft.Graph/Enums/GraphErrorCode.cs).
24+
You can check the status code that caused the error as below.
25+
26+
```csharp
27+
catch (ODataError odataError) when (odataError.ResponseStatusCode.Equals(HttpStatusCode.NotFound))
28+
{
29+
// Handle 404 status code
30+
}
31+
```
32+
33+
## Checking the error
1134

12-
### Checking the error code
13-
You can easily check if an error has a specific code by calling `IsMatch` on the error code value. `IsMatch` is not case sensitive:
35+
There are a few different types of errors that can occur during a network call. These most common error codes are defined in [GraphErrorCode.cs](../src/Microsoft.Graph/Enums/GraphErrorCode.cs). These can be checked by matching with the error code value as below.
1436

1537
```csharp
16-
if (exception.IsMatch(GraphErrorCode.AccessDenied.ToString())
38+
catch (ODataError odataError) when (odataError.Error.Code.Equals(GraphErrorCode.AccessDenied.ToString()))
1739
{
1840
// Handle access denied error
1941
}
2042
```
2143

22-
Each error object has a `Message` property as well as code. This message is for debugging purposes and is not be meant to be displayed to the user. Common error codes are defined in [GraphErrorCode.cs](../src/Microsoft.Graph/Enums/GraphErrorCode.cs).
44+
Each error object has a `Message` property as well as code. This message is for debugging purposes and is not be meant to be displayed to the user. Common error codes are defined in [GraphErrorCode.cs](../src/Microsoft.Graph/Enums/GraphErrorCode.cs).

docs/upgrade-to-v4.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,63 @@ var device = await graphClient.DeviceManagement.ManagedDevices["1"].Request().Ge
126126
Assert.Equal("1",device.Id);
127127
```
128128

129+
### Collection responses do not have @odata.nextLink in the AdditionalData
130+
131+
Response for collection types are now deserialized into the NextLink property in the collection response object(example [here](https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/23e9386538993ebe08ba88c084831b6163304e27/src/Microsoft.Graph/Generated/requests/AccessPackageAssignmentFilterByCurrentUserCollectionResponse.cs#L31)) and are not available in the additionalData bag. The property is then used to automatically initialize the nextPage request for the collection page and can be accessed as below.
132+
133+
```cs
134+
var users = await graphServiceClient.Users.Request().GetAsync();
135+
var nextLink = users.NextPageRequest.GetHttpRequestMessage().RequestUri.OriginalString;
136+
```
137+
138+
#### Note
139+
It is recommended to use the PageIterator when paging through collections as this allows for advance functionality such as configuring pausing, managing state and access to the DeltaLink and NextLink if needed. An example of using the PageIterator with delta is shown below.
140+
141+
```cs
142+
int count = 0;
143+
int pauseAfter = 25;
144+
145+
var messages = await graphClient.Me.Messages
146+
.Request()
147+
.Select(e => new {
148+
e.Sender,
149+
e.Subject
150+
})
151+
.Top(10)
152+
.GetAsync();
153+
154+
var pageIterator = PageIterator<Message>
155+
.CreatePageIterator(
156+
graphClient,
157+
messages,
158+
(m) =>
159+
{
160+
Console.WriteLine(m.Subject);
161+
count++;
162+
// If we've iterated over the limit,
163+
// stop the iteration by returning false
164+
return count < pauseAfter;
165+
}
166+
);
167+
168+
await pageIterator.IterateAsync();
169+
170+
while (pageIterator.State != PagingState.Complete)
171+
{
172+
if (pageIterator.State == PagingState.Delta)
173+
{
174+
string deltaLink = pageIterator.Deltalink;
175+
Console.WriteLine($"Paged through results and found deltaLink : {deltaLink}");
176+
}
177+
178+
Console.WriteLine("Iteration paused for 5 seconds...");
179+
await Task.Delay(5000);
180+
// Reset count
181+
count = 0;
182+
await pageIterator.ResumeAsync();
183+
}
184+
```
185+
129186
## New capabilities
130187

131188
### Azure Identity

src/Microsoft.Graph/Enums/GraphErrorCode.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public enum GraphErrorCode
8080
NameAlreadyExists,
8181
/// The action is not allowed by the system.
8282
NotAllowed,
83+
/// The requested item is not not found.
84+
NotFound,
8385
/// The request is not supported by the system.
8486
NotSupported,
8587
/// Parameter Exceeds Maximum Length.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
using Microsoft.Kiota.Abstractions.Serialization;
6+
using Microsoft.Kiota.Abstractions.Store;
7+
using System;
8+
using System.Collections.Generic;
9+
10+
namespace Microsoft.Graph.Models;
11+
12+
public class PlannerAssignment: IAdditionalDataHolder, IBackedModel, IParsable
13+
{
14+
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
15+
public IDictionary<string, object> AdditionalData {
16+
get { return BackingStore?.Get<IDictionary<string, object>>("additionalData"); }
17+
set { BackingStore?.Set("additionalData", value); }
18+
}
19+
/// <summary>Stores model information.</summary>
20+
public IBackingStore BackingStore { get; private set; }
21+
/// <summary>The OdataType property</summary>
22+
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
23+
#nullable enable
24+
public string? OdataType {
25+
get { return BackingStore?.Get<string?>("@odata.type"); }
26+
set { BackingStore?.Set("@odata.type", value); }
27+
}
28+
#nullable restore
29+
#else
30+
public string OdataType {
31+
get { return BackingStore?.Get<string>("@odata.type"); }
32+
set { BackingStore?.Set("@odata.type", value); }
33+
}
34+
#endif
35+
/// <summary>The OdataType property</summary>
36+
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
37+
#nullable enable
38+
public string? OrderHint {
39+
get { return BackingStore?.Get<string?>("orderHint"); }
40+
set { BackingStore?.Set("orderHint", value); }
41+
}
42+
#nullable restore
43+
#else
44+
public string OrderHint {
45+
get { return BackingStore?.Get<string>("orderHint"); }
46+
set { BackingStore?.Set("orderHint", value); }
47+
}
48+
#endif
49+
/// <summary>
50+
/// Instantiates a new auditActivityInitiator and sets the default values.
51+
/// </summary>
52+
public PlannerAssignment() {
53+
BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore();
54+
AdditionalData = new Dictionary<string, object>();
55+
OdataType = "#microsoft.graph.plannerAssignment";
56+
OrderHint = "!";
57+
}
58+
/// <summary>
59+
/// Creates a new instance of the appropriate class based on discriminator value
60+
/// </summary>
61+
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
62+
public static PlannerAssignment CreateFromDiscriminatorValue(IParseNode parseNode) {
63+
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
64+
return new PlannerAssignment();
65+
}
66+
/// <summary>
67+
/// The deserialization information for the current model
68+
/// </summary>
69+
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
70+
return new Dictionary<string, Action<IParseNode>> {
71+
{"@odata.type", n => { OdataType = n.GetStringValue(); } },
72+
{"orderHint", n => { OrderHint = n.GetStringValue(); } },
73+
};
74+
}
75+
/// <summary>
76+
/// Serializes information the current object
77+
/// </summary>
78+
/// <param name="writer">Serialization writer to use to serialize this model</param>
79+
public void Serialize(ISerializationWriter writer) {
80+
_ = writer ?? throw new ArgumentNullException(nameof(writer));
81+
writer.WriteStringValue("@odata.type", OdataType);
82+
writer.WriteStringValue("orderHint", OrderHint);
83+
writer.WriteAdditionalData(AdditionalData);
84+
}
85+
}

src/Microsoft.Graph/Generated/Chats/Item/Messages/Item/Replies/RepliesRequestBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public async Task<ChatMessageCollectionResponse> GetAsync(Action<RepliesRequestB
8484
return await RequestAdapter.SendAsync<ChatMessageCollectionResponse>(requestInfo, ChatMessageCollectionResponse.CreateFromDiscriminatorValue, errorMapping, cancellationToken);
8585
}
8686
/// <summary>
87-
/// Create a new reply to a chatMessage in a specified channel.
88-
/// Find more info here <see href="https://docs.microsoft.com/graph/api/channel-post-messagereply?view=graph-rest-1.0" />
87+
/// Send a new reply to a chatMessage in a specified channel.
88+
/// Find more info here <see href="https://docs.microsoft.com/graph/api/chatmessage-post-replies?view=graph-rest-1.0" />
8989
/// </summary>
9090
/// <param name="body">The request body</param>
9191
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
@@ -132,7 +132,7 @@ public RequestInformation ToGetRequestInformation(Action<RepliesRequestBuilderGe
132132
return requestInfo;
133133
}
134134
/// <summary>
135-
/// Create a new reply to a chatMessage in a specified channel.
135+
/// Send a new reply to a chatMessage in a specified channel.
136136
/// </summary>
137137
/// <param name="body">The request body</param>
138138
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>

src/Microsoft.Graph/Generated/Chats/Item/Messages/MessagesRequestBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public async Task<ChatMessageCollectionResponse> GetAsync(Action<MessagesRequest
8484
return await RequestAdapter.SendAsync<ChatMessageCollectionResponse>(requestInfo, ChatMessageCollectionResponse.CreateFromDiscriminatorValue, errorMapping, cancellationToken);
8585
}
8686
/// <summary>
87-
/// Send a new chatMessage in the specified channel or a chat.
88-
/// Find more info here <see href="https://docs.microsoft.com/graph/api/chatmessage-post?view=graph-rest-1.0" />
87+
/// Send a new chatMessage in the specified chat. This API can&apos;t create a new chat; you must use the list chats method to retrieve the ID of an existing chat before you can create a chat message.
88+
/// Find more info here <see href="https://docs.microsoft.com/graph/api/chat-post-messages?view=graph-rest-1.0" />
8989
/// </summary>
9090
/// <param name="body">The request body</param>
9191
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
@@ -132,7 +132,7 @@ public RequestInformation ToGetRequestInformation(Action<MessagesRequestBuilderG
132132
return requestInfo;
133133
}
134134
/// <summary>
135-
/// Send a new chatMessage in the specified channel or a chat.
135+
/// Send a new chatMessage in the specified chat. This API can&apos;t create a new chat; you must use the list chats method to retrieve the ID of an existing chat before you can create a chat message.
136136
/// </summary>
137137
/// <param name="body">The request body</param>
138138
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>

src/Microsoft.Graph/Generated/Communications/Calls/Item/Participants/Invite/InviteRequestBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public InviteRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) {
4747
RequestAdapter = requestAdapter;
4848
}
4949
/// <summary>
50-
/// Invite participants to the active call. For more information about how to handle operations, see commsOperation.
51-
/// Find more info here <see href="https://docs.microsoft.com/graph/api/participant-invite?view=graph-rest-1.0" />
50+
/// Delete a specific participant in a call. In some situations, it is appropriate for an application to remove a participant from an active call. This action can be done before or after the participant answers the call. When an active caller is removed, they are immediately dropped from the call with no pre- or post-removal notification. When an invited participant is removed, any outstanding add participant request is canceled.
51+
/// Find more info here <see href="https://docs.microsoft.com/graph/api/participant-delete?view=graph-rest-1.0" />
5252
/// </summary>
5353
/// <param name="body">The request body</param>
5454
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
@@ -69,7 +69,7 @@ public async Task<InviteParticipantsOperation> PostAsync(InvitePostRequestBody b
6969
return await RequestAdapter.SendAsync<InviteParticipantsOperation>(requestInfo, InviteParticipantsOperation.CreateFromDiscriminatorValue, errorMapping, cancellationToken);
7070
}
7171
/// <summary>
72-
/// Invite participants to the active call. For more information about how to handle operations, see commsOperation.
72+
/// Delete a specific participant in a call. In some situations, it is appropriate for an application to remove a participant from an active call. This action can be done before or after the participant answers the call. When an active caller is removed, they are immediately dropped from the call with no pre- or post-removal notification. When an invited participant is removed, any outstanding add participant request is canceled.
7373
/// </summary>
7474
/// <param name="body">The request body</param>
7575
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>

0 commit comments

Comments
 (0)