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

Workbooks: Update range of a worksheet not implemented in sdk

Open lombold opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe the problem.

I want to update a range within a worksheet and noticed that the update range endoint (PATCH /drive/items/{id}/workbook/worksheets/{sheet-id}/range(address='A1:B2')) cannot be called via the msgraph-sdk for java.

API Docs: https://learn.microsoft.com/en-us/graph/api/range-update?view=graph-rest-1.0&tabs=http

SDK-Version: 6.18.0

Describe the solution you'd like.

I would be glad if you could extend the sdk to support this functionality.

E.g. something like this:

myGraphServiceClient
          .drives()
          .byDriveId(driveId)
          .items()
          .byDriveItemId(documentId)
          .workbook()
          .worksheets()
          .byWorkbookWorksheetId(worksheet)
          .rangeWithAddress(address)
          .patch(patchRequest);

Additional context?

My current workaround is

final var updateRangeRequest = new UntypedObject(Map.of(
    "values", new UntypedArray(Arrays.asList(
      new UntypedArray(Arrays.asList(
        new UntypedString(value)
      ))
    ))
  ));


  final var requestInfo = graphServiceClient
    .drives()
    .byDriveId(this.driveId)
    .items()
    .byDriveItemId(documentId)
    .workbook()
    .worksheets()
    .byWorkbookWorksheetId(worksheet)
    .rangeWithAddress(address)
    .toGetRequestInformation();

// Convert the get-request to the desired patch
  requestInfo.headers.tryAdd("workbook-session-id", sessionId);
  requestInfo.httpMethod = HttpMethod.PATCH;
  requestInfo.setContentFromParsable(graphServiceClient.getRequestAdapter(), "application/json", updateRangeRequest);

// Copied from sdk
  HashMap<String, ParsableFactory<? extends Parsable>> errorMapping = new HashMap();
  errorMapping.put("XXX", ODataError::createFromDiscriminatorValue);
  
  final var updatedRange = (WorkbookRange) graphServiceClient.getRequestAdapter()
    .send(requestInfo, errorMapping, WorkbookRange::createFromDiscriminatorValue);

lombold avatar Oct 17 '24 09:10 lombold