我正在尝试使用 microsoft graph api 获取和发布方法。Java代码:
IGraphServiceClient graphClient =
GraphServiceClient.builder().authenticationProvider(authProvider)
.buildClient();
graphClient.me().calendar().events().buildRequest().post(event);
User user = graphClient.me().buildRequest().get();
Run Code Online (Sandbox Code Playgroud)
在访问 api 时,我收到此错误:
线程“main”中出现异常 java.lang.NoSuchMethodError: okhttp3.Request$Builder.tag(Ljava/lang/Class;Ljava/lang/Object;)Lokhttp3/Request$Builder; 在 com.microsoft.graph.http.CoreHttpProvider.getHttpRequest(CoreHttpProvider.java:257) 在 com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:397) 在 com.microsoft.graph.http.CoreHttpProvider.send (CoreHttpProvider.java:220)在com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:200)在com.microsoft.graph.http.BaseRequest.send(BaseRequest.java:345)在com.microsoft。 graph.requests.extensions.EventRequest.post(EventRequest.java:135) at com.microsoft.graph.requests.extensions.EventCollectionRequest.post(EventCollectionRequest.java:75)
graph 和 graph-auth api 的 Maven 版本是:
<!-- https://mvnrepository.com/artifact/com.microsoft.graph/microsoft-graph -->
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
<version>2.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.microsoft.graph/microsoft-graph-auth -->
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph-auth</artifactId>
<version>0.3.0-SNAPSHOT</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题吗?
这是主要方法:
public static void main(String[] args) {
UsernamePasswordProvider authProvider = new UsernamePasswordProvider("{client_id}",
Arrays.asList("https://graph.microsoft.com/.default"),
"{username}", "{password}", NationalCloud.Global,
"{tenant_id}", "{client_secret}");
IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider(authProvider)
.buildClient();
Event event …Run Code Online (Sandbox Code Playgroud)