4,374 questions
Getting error in updating the Graph API version for creating worksheet
Ashish Kumar
5
Reputation points
Hello there,
I have written some code for my project, where I'm creating the worksheet using the Graph API version 5.42 in Java.
Now I'm updating the version to the latest one, and it is not showing the below error for the respective code.
Error showing in the below code:
Cannot resolve method 'me()'
Cannot resolve symbol 'WorkbookWorksheetAddParameterSet'
Cannot resolve symbol 'GraphServiceException'
Code:
import com.microsoft.graph.http.GraphServiceException;
import com.microsoft.graph.models.*;
import com.microsoft.graph.options.HeaderOption;
import com.microsoft.graph.requests.GraphServiceClient;
import com.microsoft.graph.requests.WorkbookWorksheetRangeRequest;
private GraphServiceClient client;
public boolean createWorksheet(String worksheetName) {
try {
// API call to create new worksheet
client.me()
.drive()
.root()
.itemWithPath(workbookPath)
.workbook()
.worksheets()
.add(
WorkbookWorksheetAddParameterSet.newBuilder()
.withName(Utils.encodeString(worksheetName))
.build())
.buildRequest(workbookSessionIdHeader)
.post();
setActiveSheetName(worksheetName);
return true;
} catch (GraphServiceException exception) {
System.err.println("Graph service encountered an error: " + exception.getMessage());
}
}
This code worked perfectly fine with the older API version, but it's breaking with the newer API version.
Microsoft 365 and Office Development Other
Microsoft 365 and Office Install, redeem, activate For business Windows
Microsoft Security Microsoft Graph
13,721 questions
Sign in to answer