smartsheet / smartsheet-java-sdk

Library that uses Java to connect to Smartsheet services.
Apache License 2.0
5 stars 13 forks source link

Bugfix: When fetching discussions, comment attachments were not included if pagination parameters were specified #102

Closed smar-alejandro-mendez closed 2 months ago

smar-alejandro-mendez commented 2 months ago

Summary

When fetching discussions for a row, there is an option to fetch the comments associated with each discussion and the attachments for each comment. There is a bug in the SDK that is preventing the attachments for comments from being returned if the user specifies paging parameters.

PaginationParameters parameters = new PaginationParameters.PaginationParametersBuilder().setIncludeAll(true).build();
EnumSet<DiscussionInclusion> discussionInclusions = EnumSet.of(DiscussionInclusion.COMMENTS, DiscussionInclusion.ATTACHMENTS);
PagedResult<Discussion> discussion = smartsheet
                .sheetResources()
                .rowResources()
                .discussionResources()
                .listDiscussions(sheet.getId(), row.getId(), parameters, discussionInclusions);
List<Attachments> attachments = newDiscussion.getData().get(0).getComments().get(0).getAttachments(); 
attachments <---- attachments are null

This is happening because, when building the URL path to retrieve the list of discussions, if we specify both include parameters and pagination parameters, the resulting path has two "?" characters:

sheets/8124026088056708/rows/3056197762541444/discussions?include=comments,attachments?includeAll=true

When this happens, the Smartsheet API will ignore the include parameter and only take into account the includeAll parameter.

In this PR we are making sure that when both pagination parameters and include parameters are specified, the resulting path is built correctly:

sheets/8124026088056708/rows/3056197762541444/discussions?include=comments,attachments&includeAll=true
zromano commented 2 months ago

Nice find. Thanks for fixing this!