msgraph-sdk-java icon indicating copy to clipboard operation
msgraph-sdk-java copied to clipboard

PlannerAssignment class does not exist in version 6.4.0

Open HermanShpryhau opened this issue 11 months ago • 10 comments

In the docs for creating a task the PlannerAssignment is mentioned in the code example, but this class is not present in the library.

HermanShpryhau avatar Mar 04 '24 09:03 HermanShpryhau

Thanks for reporting this @HermanShpryhau.

While this is being investigated, you can try using a HashMap to hold the plannerAssignment properties and values as follows. Lmk if this unblocks you:

PlannerAssignments assignments = new PlannerAssignments();
HashMap<String, Object> additionalData = new HashMap<>();
additionalData.put("[user-id]", "{'@odata.type':'#microsoft.graph.plannerAssignment','orderHint':' !'}");
assignments.setAdditionalData(additionalData);

Ndiritu avatar Mar 04 '24 10:03 Ndiritu

(Triage notes) PlannerAssignments is an open type. PlannerAssignment(no 's') is declared as a component in the OpenAPI spec but not generated by Kiota. Could this be because it's not references as an optional property of plannerAssignments?

Ndiritu avatar Mar 04 '24 10:03 Ndiritu

Unfortunately putting a map there results in following exception:

java.lang.IllegalStateException: Dangling name: 27a1c9e1-8745-43b6-b8e1-bd2493ed5ac8
	at com.google.gson.stream.JsonWriter.close(JsonWriter.java:346) ~[gson-2.10.1.jar:na]
	at com.google.gson.stream.JsonWriter.endObject(JsonWriter.java:321) ~[gson-2.10.1.jar:na]
	at com.microsoft.kiota.serialization.JsonSerializationWriter.writeObjectValue(JsonSerializationWriter.java:307) ~[microsoft-kiota-serialization-json-1.0.4.jar:na]
	at com.microsoft.graph.models.PlannerTask.serialize(PlannerTask.java:273) ~[microsoft-graph-6.4.0.jar:na]
	at com.microsoft.kiota.serialization.JsonSerializationWriter.writeObjectValue(JsonSerializationWriter.java:292) ~[microsoft-kiota-serialization-json-1.0.4.jar:na]
	at com.microsoft.kiota.RequestInformation.setContentFromParsable(RequestInformation.java:358) ~[microsoft-kiota-abstractions-1.0.4.jar:na]
	at com.microsoft.graph.planner.tasks.TasksRequestBuilder.toPostRequestInformation(TasksRequestBuilder.java:154) ~[microsoft-graph-6.4.0.jar:na]
	at com.microsoft.graph.planner.tasks.TasksRequestBuilder.post(TasksRequestBuilder.java:108) ~[microsoft-graph-6.4.0.jar:na]
	at com.microsoft.graph.planner.tasks.TasksRequestBuilder.post(TasksRequestBuilder.java:95) ~[microsoft-graph-6.4.0.jar:na]

I also tried creating a GSON json object and putting it there. Didn't help either.

HermanShpryhau avatar Mar 04 '24 11:03 HermanShpryhau

My apologies @HermanShpryhau. I meant to pass the JSON string value. Updated the sample.

Ndiritu avatar Mar 04 '24 12:03 Ndiritu

The string approach didn't work for me either. I don't have logs at hand currently unfortunately.

HermanShpryhau avatar Mar 07 '24 08:03 HermanShpryhau

The string approach didn't work. This is the error log:

Exception in thread "main" com.microsoft.graph.models.odataerrors.ODataError: An open type property has an invalid type.
	at com.microsoft.graph.models.odataerrors.ODataError.createFromDiscriminatorValue(ODataError.java:36)
	at com.microsoft.kiota.serialization.JsonParseNode.getObjectValue(JsonParseNode.java:210)
	at com.microsoft.kiota.http.OkHttpRequestAdapter.lambda$throwIfFailedResponse$0(OkHttpRequestAdapter.java:672)
	at com.microsoft.kiota.ApiExceptionBuilder.<init>(ApiExceptionBuilder.java:26)
	at com.microsoft.kiota.http.OkHttpRequestAdapter.throwIfFailedResponse(OkHttpRequestAdapter.java:671)
	at com.microsoft.kiota.http.OkHttpRequestAdapter.send(OkHttpRequestAdapter.java:279)
	at com.microsoft.graph.planner.tasks.TasksRequestBuilder.post(TasksRequestBuilder.java:111)
	at com.microsoft.graph.planner.tasks.TasksRequestBuilder.post(TasksRequestBuilder.java:95)
	at org.example.Main.main(Main.java:39)

Eleirbag89 avatar Mar 13 '24 11:03 Eleirbag89

(Triage notes) PlannerAssignments is an open type. PlannerAssignment(no 's') is declared as a component in the OpenAPI spec but not generated by Kiota. Could this be because it's not references as an optional property of plannerAssignments?

@baywet when you have some time, might you be able to share more on this?

Ndiritu avatar Mar 13 '24 14:03 Ndiritu

The string approach didn't work. This is the error log:

Exception in thread "main" com.microsoft.graph.models.odataerrors.ODataError: An open type property has an invalid type.
	at com.microsoft.graph.models.odataerrors.ODataError.createFromDiscriminatorValue(ODataError.java:36)
	at com.microsoft.kiota.serialization.JsonParseNode.getObjectValue(JsonParseNode.java:210)
	at com.microsoft.kiota.http.OkHttpRequestAdapter.lambda$throwIfFailedResponse$0(OkHttpRequestAdapter.java:672)
	at com.microsoft.kiota.ApiExceptionBuilder.<init>(ApiExceptionBuilder.java:26)
	at com.microsoft.kiota.http.OkHttpRequestAdapter.throwIfFailedResponse(OkHttpRequestAdapter.java:671)
	at com.microsoft.kiota.http.OkHttpRequestAdapter.send(OkHttpRequestAdapter.java:279)
	at com.microsoft.graph.planner.tasks.TasksRequestBuilder.post(TasksRequestBuilder.java:111)
	at com.microsoft.graph.planner.tasks.TasksRequestBuilder.post(TasksRequestBuilder.java:95)
	at org.example.Main.main(Main.java:39)

Apologies @Eleirbag89 @HermanShpryhau . Realised this doesn't work because the body of the user-Id in the assignments property is sent as a JSON string instead of an object. Will investigate the root cause further

Ndiritu avatar Mar 13 '24 14:03 Ndiritu

@Ndiritu I think this is one of the very few OData Dictionary usage across the API surface. @TarkanSevilmis is the architect for that API and could confirm that. PlannerAssignements is a dictionary key string value PlannerAssignment. But because OpenAPI.net doesn't support OAI 3.1 yet which brings support for dictionaries, openapi.net.odata cannot convert things properly. That means we don't have a reference to PlannerAssignment in the description, so it gets trimmed away by kiota during the generation. And whenever support for it in OpenAPI.net and OpenAPI.net.OData is added for it, adding support in kiota will be a breaking change (additions to the SerializationWriter and ParseNode interfaces).

All that to say:

  • it's an issue we probably have across languages.
  • it's going to take a while to be solved.

We should probably direct the customer to make an arbitrary request for this one.

baywet avatar Mar 18 '24 17:03 baywet