Skip to content

Commit 7330fe7

Browse files
Merge pull request #140 from microsoftgraph/dev
Merge updates for June 2017 release
2 parents 9e2c2bc + dec97e6 commit 7330fe7

File tree

358 files changed

+21721
-131
lines changed

Some content is hidden

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

358 files changed

+21721
-131
lines changed

docs/overview.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,51 @@ Expand, Skip, Top, OrderBy, and Filter are also supported via the client library
115115
## Collections
116116

117117
Please see [collections](/docs/collections.md) for details on collections and paging.
118+
119+
## Send HTTP requests with the .Net Microsoft Graph client library
120+
121+
Sometimes, the functionality that you want to use isn't a part of the .NET client library. In this case, you can still use the client library to make your life easier. The client library can authenticate your requests and provide you the serializers. Here's an example of using the client library to create a OneNote page and deserialize the response object.
122+
123+
```csharp
124+
125+
public async Task OneNoteAddPageHtml()
126+
{
127+
// Get a page of OneNote sections.
128+
IOnenoteSectionsCollectionPage sectionPage = await graphClient.Me.Onenote.Sections.Request().GetAsync();
129+
130+
// Get a handle to the first section.
131+
string sectionId = sectionPage[0].Id;
132+
133+
// Get the request URL for adding a page.
134+
string requestUrl = graphClient.Me.Onenote.Sections[sectionId].Pages.Request().RequestUrl;
135+
136+
string htmlBody = @"<!DOCTYPE html><html><head><title>OneNoteAddPageHtml created this</title></head>
137+
<body>Generated with love</body></html> ";
138+
139+
// Create the request message and add the content.
140+
HttpRequestMessage hrm = new HttpRequestMessage(HttpMethod.Post, requestUrl);
141+
hrm.Content = new StringContent(htmlBody, System.Text.Encoding.UTF8, "text/html");
142+
143+
// Authenticate (add access token) our HttpRequestMessage
144+
await graphClient.AuthenticationProvider.AuthenticateRequestAsync(hrm);
145+
146+
// Send the request and get the response.
147+
HttpResponseMessage response = await graphClient.HttpProvider.SendAsync(hrm);
148+
149+
// Get the OneNote page that we created.
150+
if (response.IsSuccessStatusCode)
151+
{
152+
// Deserialize into OneNotePage object.
153+
var content = await response.Content.ReadAsStringAsync();
154+
OnenotePage page = graphClient.HttpProvider.Serializer.DeserializeObject<OnenotePage>(content);
155+
}
156+
else
157+
throw new ServiceException(
158+
new Error
159+
{
160+
Code = response.StatusCode.ToString(),
161+
Message = await response.Content.ReadAsStringAsync()
162+
});
163+
}
164+
165+
```

src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,25 @@
33
<Description>Microsoft Graph Core Client Library implements core functionality used by Microsoft Graph Client Libraries.</Description>
44
<Copyright>Copyright (c) Microsoft Corporation</Copyright>
55
<AssemblyTitle>Microsoft Graph Core Client Library</AssemblyTitle>
6-
<VersionPrefix>1.4.0</VersionPrefix>
6+
<VersionPrefix>1.5.0</VersionPrefix>
7+
<FileVersion>1.5.0</FileVersion>
8+
<AssemblyVersion>1.5.0</AssemblyVersion>
79
<Authors>Microsoft</Authors>
810
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>
911
<AssemblyName>Microsoft.Graph.Core</AssemblyName>
1012
<PackageId>Microsoft.Graph.Core</PackageId>
1113
<PackageTags>Microsoft Office365;Graph;GraphServiceClient;Outlook;OneDrive;AzureAD;GraphAPI;Productivity;SharePoint;SDK</PackageTags>
1214
<PackageReleaseNotes>
13-
May 2017 Release Summary (version 1.4.0)
15+
June 2017 Release Summary (version 1.5.0)
1416

1517
New features
1618

17-
* Added support for .NetStandard 1.1
19+
* Support for posting multipart content.
1820

19-
Updates
21+
Bug fixes
22+
23+
* Boolean query string parameters are no longer emitted in upper case.
2024

21-
* Updated dependency on Newtonsoft.Json to 10.0.2.
22-
* Removed the Exception ToString override
2325
</PackageReleaseNotes>
2426
<PackageProjectUrl>https://graph.microsoft.io</PackageProjectUrl>
2527
<PackageLicenseUrl>http://aka.ms/devservicesagreement</PackageLicenseUrl>

src/Microsoft.Graph.Core/Microsoft.Graph.Core.nuspec

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/Microsoft.Graph.Core/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
//
2525
// You can specify all the values or you can default the Build and Revision Numbers
2626
// by using the '*' as shown below:
27-
[assembly: AssemblyVersion("1.4.0")]
28-
[assembly: AssemblyFileVersion("1.4.0.0")]
27+
[assembly: AssemblyVersion("1.5.0")]
28+
[assembly: AssemblyFileVersion("1.5.0.0")]
2929

3030
#if DEBUG
3131
[assembly: InternalsVisibleTo("Microsoft.Graph.Core.Test")]

src/Microsoft.Graph.Core/Requests/BaseFunctionMethodRequestBuilder.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ protected void SetParameter(string name, object value, bool nullable)
9494
else if (!passParametersInQueryString)
9595
{
9696
string valueAsString = value != null ? value.ToString() : "null";
97+
if (value is bool)
98+
{
99+
valueAsString = valueAsString.ToLower();
100+
}
101+
97102
if (value != null && value is string)
98103
{
99104
valueAsString = "'" + EscapeStringValue(valueAsString) + "'";

src/Microsoft.Graph.Core/Requests/BaseRequest.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,31 @@ public async Task<T> SendAsync<T>(
137137
}
138138
}
139139

140+
/// <summary>
141+
/// Sends the multipart request.
142+
/// </summary>
143+
/// <typeparam name="T">The expected response object type for deserialization.</typeparam>
144+
/// <param name="multipartContent">The multipart object to send.</param>
145+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
146+
/// <param name="completionOption">The <see cref="HttpCompletionOption"/> to pass to the <see cref="IHttpProvider"/> on send.</param>
147+
/// <returns>The deserialized response object.</returns>
148+
public async Task<T> SendMultiPartAsync<T>(
149+
MultipartContent multipartContent,
150+
CancellationToken cancellationToken,
151+
HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead)
152+
{
153+
using (var response = await this.SendMultiPartRequestAsync(multipartContent, cancellationToken, completionOption).ConfigureAwait(false))
154+
{
155+
if (response.Content != null)
156+
{
157+
var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
158+
return this.Client.HttpProvider.Serializer.DeserializeObject<T>(responseString);
159+
}
160+
161+
return default(T);
162+
}
163+
}
164+
140165
/// <summary>
141166
/// Sends the request.
142167
/// </summary>
@@ -154,6 +179,56 @@ public async Task<Stream> SendStreamRequestAsync(
154179
return await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
155180
}
156181

182+
/// <summary>
183+
/// Sends the multipart request.
184+
/// </summary>
185+
/// <typeparam name="T">The expected response object type for deserialization.</typeparam>
186+
/// <param name="multipartContent">The multipart object to send.</param>
187+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
188+
/// <param name="completionOption">The <see cref="HttpCompletionOption"/> to pass to the <see cref="IHttpProvider"/> on send.</param>
189+
/// <returns>The <see cref="HttpResponseMessage"/> object.</returns>
190+
public async Task<HttpResponseMessage> SendMultiPartRequestAsync(
191+
MultipartContent multipartContent,
192+
CancellationToken cancellationToken,
193+
HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead)
194+
{
195+
if (string.IsNullOrEmpty(this.RequestUrl))
196+
{
197+
throw new ServiceException(
198+
new Error
199+
{
200+
Code = ErrorConstants.Codes.InvalidRequest,
201+
Message = ErrorConstants.Messages.RequestUrlMissing,
202+
});
203+
}
204+
205+
if (this.Client.AuthenticationProvider == null)
206+
{
207+
throw new ServiceException(
208+
new Error
209+
{
210+
Code = ErrorConstants.Codes.InvalidRequest,
211+
Message = ErrorConstants.Messages.AuthenticationProviderMissing,
212+
});
213+
}
214+
215+
if (multipartContent != null)
216+
{
217+
using (var request = this.GetHttpRequestMessage())
218+
{
219+
await this.AuthenticateRequest(request).ConfigureAwait(false);
220+
221+
request.Content = multipartContent;
222+
223+
return await this.Client.HttpProvider.SendAsync(request, completionOption, cancellationToken).ConfigureAwait(false);
224+
}
225+
}
226+
else
227+
{
228+
throw new Exception("The Multipart content is null. Set the multipart content.");
229+
}
230+
}
231+
157232
/// <summary>
158233
/// Sends the request.
159234
/// </summary>

src/Microsoft.Graph.Core/Serialization/DurationConverter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public override bool CanConvert(Type objectType)
2525
/// </summary>
2626
/// <returns>A Microsoft.Graph.Duration object.</returns>
2727
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
28-
//public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Microsoft.Graph.Serializer serializer)
2928
{
3029
try
3130
{

src/Microsoft.Graph/Microsoft.Graph.csproj

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,32 @@
44
<Description>Microsoft Graph Client Library allows you to call Office 365, Azure AD and other Microsoft services through a single unified developer experience.</Description>
55
<Copyright>Copyright (c) Microsoft Corporation</Copyright>
66
<AssemblyTitle>Microsoft Graph Client Library</AssemblyTitle>
7-
<VersionPrefix>1.3.0</VersionPrefix>
7+
<VersionPrefix>1.4.0</VersionPrefix>
8+
<FileVersion>1.4.0</FileVersion>
9+
<AssemblyVersion>1.4.0</AssemblyVersion>
810
<Authors>Microsoft</Authors>
911
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>
1012
<AssemblyName>Microsoft.Graph</AssemblyName>
1113
<PackageId>Microsoft.Graph</PackageId>
1214
<PackageTags>Microsoft Office365;Graph;GraphServiceClient;Outlook;OneDrive;AzureAD;GraphAPI;Productivity;SharePoint;SDK</PackageTags>
1315
<PackageReleaseNotes>
14-
May 2017 Release Summary (version 1.3.0)
16+
June 2017 Release Summary (version 1.4.0)
1517

1618
New features
1719

18-
* Added support for .NetStandard 1.1
19-
* Added support for Planner which includes custom serialization for Planner open types, an ETag and header helper.
20-
* Added support SharePoint.
21-
* Added support for delta queries and enum flags.
22-
* Added FindMeetingTimes functionality.
23-
* Added the sharedWithMe and copy functionality for DriveItem.
24-
* Added named items, refresh, column, row, and view functionality for Excel.
25-
* Tested support for OpenTypes - available through the AdditionalData property bag.
26-
20+
* OneNote
21+
* Open extensions
22+
* Schema extensions
23+
2724
Updates
25+
26+
* Provided example and tests for scenarios where Microsoft.Graph client library request builders don't support functionality. This way you can make use of the serializer and authentication provider.
27+
* The service metadata doesn't support GetByPath for getting SharePoint sites by relative path. Added functionality to enable this.
28+
* Added FindMeetingTimes test.
2829

29-
* Updated dependency on Newtonsoft.Json to 10.0.2.
30-
* Updated the group object to support a group photos collection, drives collection, sites collection, and a group Planner plan.
31-
* Updated the user object to support a photos collection and the user's Planner plans.
30+
Bug fixes
31+
32+
* Large file uploads larger than 2GB is enabled.
3233

3334
</PackageReleaseNotes>
3435
<PackageProjectUrl>https://graph.microsoft.io</PackageProjectUrl>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
// **NOTE** This file was generated by a tool and any changes will be overwritten.
6+
7+
// Template Source: Templates\CSharp\Model\ComplexType.cs.tt
8+
9+
namespace Microsoft.Graph
10+
{
11+
using System;
12+
using System.Collections.Generic;
13+
using System.IO;
14+
using System.Runtime.Serialization;
15+
using Newtonsoft.Json;
16+
17+
/// <summary>
18+
/// The type ComplexExtensionValue.
19+
/// </summary>
20+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
21+
[JsonConverter(typeof(DerivedTypeConverter))]
22+
public partial class ComplexExtensionValue
23+
{
24+
25+
/// <summary>
26+
/// Gets or sets additional data.
27+
/// </summary>
28+
[JsonExtensionData(ReadData = true)]
29+
public IDictionary<string, object> AdditionalData { get; set; }
30+
31+
}
32+
}

src/Microsoft.Graph/Models/Generated/Device.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ public partial class Device : DirectoryObject
123123
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "registeredUsers", Required = Newtonsoft.Json.Required.Default)]
124124
public IDeviceRegisteredUsersCollectionWithReferencesPage RegisteredUsers { get; set; }
125125

126+
/// <summary>
127+
/// Gets or sets extensions.
128+
/// </summary>
129+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "extensions", Required = Newtonsoft.Json.Required.Default)]
130+
public IDeviceExtensionsCollectionPage Extensions { get; set; }
131+
126132
}
127133
}
128134

0 commit comments

Comments
 (0)