From 12f6b8e95c0963b61bcf28a5732f333e8e96a55d Mon Sep 17 00:00:00 2001 From: "Caitlin Bales (MSFT)" Date: Fri, 2 Mar 2018 10:20:41 -0800 Subject: [PATCH 1/3] Add header option to multipart helper --- .../graph/models/extensions/Multipart.java | 14 ++++++++++++-- .../microsoft/graph/functional/OneNoteTests.java | 5 ++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/microsoft/graph/models/extensions/Multipart.java b/src/main/java/com/microsoft/graph/models/extensions/Multipart.java index e0597873aeb..3a2a9aad306 100644 --- a/src/main/java/com/microsoft/graph/models/extensions/Multipart.java +++ b/src/main/java/com/microsoft/graph/models/extensions/Multipart.java @@ -7,6 +7,8 @@ import java.math.BigInteger; import java.security.SecureRandom; +import com.microsoft.graph.options.HeaderOption; + /** * Helper for submitting multipart data * @@ -29,12 +31,20 @@ public Multipart() { /** * Get the multipart boundary for use in the request header - * @return The multipart boundary + * @return the multipart boundary */ public String boundary() { return boundary; } + /** + * Get the Content-Type header to send the multipart request + * @return the multipart header option + */ + public HeaderOption header() { + return new HeaderOption("Content-Type", "multipart/form-data; boundary=\"" + boundary + "\""); + } + /** * Add a string part to the multipart body * @param name The name of the part @@ -76,7 +86,7 @@ public void addHtmlPart(String name, String content) throws IOException { } /** - * Add an image part to the multipart body + * Add an image/jpeg part to the multipart body * @param name The name of the part * @param imageFile The image file * @throws IOException Throws an exception if the output stream cannot be written to diff --git a/src/test/java/com/microsoft/graph/functional/OneNoteTests.java b/src/test/java/com/microsoft/graph/functional/OneNoteTests.java index d96f153c7ef..072ea1d59f7 100644 --- a/src/test/java/com/microsoft/graph/functional/OneNoteTests.java +++ b/src/test/java/com/microsoft/graph/functional/OneNoteTests.java @@ -5,6 +5,7 @@ import com.microsoft.graph.requests.extensions.IOnenotePageCollectionPage; import com.microsoft.graph.requests.extensions.IOnenoteSectionCollectionPage; import com.microsoft.graph.requests.extensions.ISectionGroupCollectionPage; +import com.microsoft.graph.serializer.AdditionalDataManager; import com.microsoft.graph.requests.extensions.IOnenoteRequestBuilder; import com.microsoft.graph.models.extensions.Multipart; import com.microsoft.graph.models.extensions.Notebook; @@ -408,9 +409,7 @@ public void testMultipartPost(){ // Add multipart request header List