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

Unable to message: createForward Returning Null Pointer Exception

Open raghucha opened this issue 1 year ago • 1 comments

Describe the bug

As described in documentation createForward. The code functionality is broken

It throws a Null Pointer exception

Expected behavior

the below code is expected to create a Draft message var result = graphClient.me().messages().byMessageId("{message-id}").createForward().post(null);

How to reproduce

graphServiceClient
        .users()
        .byUserId("[email protected]")
        .messages()
        .byMessageId("{replace-message-id}")
        .createForward().post(null);

SDK Version

6.16.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log

Exception in thread "main" java.lang.NullPointerException at java.util.Objects.requireNonNull(Objects.java:203) at com.microsoft.graph.users.item.messages.item.createforward.CreateForwardRequestBuilder.post(CreateForwardRequestBuilder.java:59) at com.microsoft.graph.users.item.messages.item.createforward.CreateForwardRequestBuilder.post(CreateForwardRequestBuilder.java:47) at org.example.Main.main(Main.java:97)

Configuration

No response

Other information

No response

raghucha avatar Oct 01 '24 16:10 raghucha

@raghucha thank you for creating this issue.

This is an issue with the code snippet. Passing a new "empty" body object should work:

var result = graphClient.me().messages().byMessageId("{message-id}").createForward().post(new CreateForwardPostRequestBody()); 

Lmk if this helps.

Ndiritu avatar Oct 03 '24 07:10 Ndiritu