Repository: microsoftgraph/msgraph-sdk-java
Issue: Conflict behavior parameter set via AdditionalDataManager on DriveItemUploadableProperties is not serialized correctly in the request body

Unfortunately the fix for #393 in 2.1.0 is not okay.
Expected behavior
{
  "item": {
    "@microsoft.graph.conflictBehavior": "rename",
    "name": "vacation.gif"
  }
}

See API reference.
Actual behavior
{
  "item": {
    "name": "vacation.gif"
  }
  "@microsoft.graph.conflictBehavior": "rename"
}

The @microsoft.graph.conflictBehavior property is ignored by the service.
Steps to reproduce the behavior
DriveItemUploadableProperties upProps = new DriveItemUploadableProperties();
upProps.name = "vacation.gif";
upProps.additionalDataManager().put("@microsoft.graph.conflictBehavior", new JsonPrimitive("rename"));

// Create an upload session
UploadSession uploadSession = graphClient
    .me()
    .drive()
    .root()
    // itemPath like "/Folder/file.txt"
    // does not need to be a path to an existing item
    .itemWithPath(itemPath)
    .createUploadSession(upProps)
    .buildRequest()
    .post();

Proposed fix
Add @microsoft.graph.conflictBehavior to the DriveItemUploadableProperties class just like @odata.type:
    @SerializedName("@microsoft.graph.conflictBehavior")
    @Expose
    public String conflictBehavior;

Then we can set the conflict behavior by upProps.conflictBehavior = "rename"; and the parameter gets added to the item property correctly.
[AB#6034](https://microsoftgraph.visualstudio.com/0985d294-5762-4bc2-a565-161ef349ca3e/_workitems/edit/6034)

Changed files:
src/test/java/com/microsoft/graph/serializer/AdditionalDataTests.java, src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java

diff --git a/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java b/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java
index 822ed586b4..bbac784612 100644
--- a/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java
+++ b/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java
@@ -196,9 +196,10 @@ public class DefaultSerializer implements ISerializer {
                 if(outJson.has(field.getName())) {
                     final Type[] interfaces = field.getType().getGenericInterfaces();
                     for(Type interfaceType : interfaces) {
-                        if(interfaceType == IJsonBackedObject.class) {
+                        if(interfaceType == IJsonBackedObject.class && outJson.get(field.getName()).isJsonObject()) {
                             try {
-                                outJsonTree = getDataFromAdditionalDataManager(outJsonTree, field.get(serializableObject));
+                                final JsonElement outdatedValue = outJson.remove(field.getName());
+                                outJson.add(field.getName(), getDataFromAdditionalDataManager(outdatedValue.getAsJsonObject(), field.get(serializableObject)));
                             } catch (IllegalAccessException ex ) {
                                 logger.logDebug("Couldn't access prop" + field.getName());
                             }
diff --git a/src/test/java/com/microsoft/graph/serializer/AdditionalDataTests.java b/src/test/java/com/microsoft/graph/serializer/AdditionalDataTests.java
index 3a068d3971..76534625ff 100644
--- a/src/test/java/com/microsoft/graph/serializer/AdditionalDataTests.java
+++ b/src/test/java/com/microsoft/graph/serializer/AdditionalDataTests.java
@@ -3,14 +3,19 @@ package com.microsoft.graph.serializer;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Before;
 import org.junit.Test;
 
+import okhttp3.Request;
+
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import com.google.gson.JsonPrimitive;
+import com.microsoft.graph.functional.TestBase;
+import com.microsoft.graph.http.HttpMethod;
 import com.microsoft.graph.logger.DefaultLogger;
 import com.microsoft.graph.models.extensions.Drive;
 import com.microsoft.graph.models.extensions.DriveItemCreateUploadSessionBody;
@@ -66,7 +71,7 @@ public class AdditionalDataTests {
 		final DriveItemCreateUploadSessionBody body = new DriveItemCreateUploadSessionBody();
 		body.item = upProps;
 		String serializedObject = serializer.serializeObject(body);
-		assertEquals("{\\"item\\":{\\"name\\":\\"vacation.gif\\"},\\"@microsoft.graph.conflictBehavior\\":\\"rename\\"}", serializedObject);
+		assertEquals("{\\"item\\":{\\"name\\":\\"vacation.gif\\",\\"@microsoft.graph.conflictBehavior\\":\\"rename\\"}}", serializedObject);
 	}
 	
 	@Test