[英]Ways to access Microsoft Graph API
I am trying to access Microsoft Graph API using the following code in Java :-我正在尝试使用以下 Java 代码访问 Microsoft Graph API:-
String url_str = "https://graph.microsoft.com/v1.0/users/";
String access_token = getAccessToken();
url = new URL(url_str);
con = ( HttpURLConnection )url.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestMethod("GET");
con.setRequestProperty("Authorization", access_token);
con.setRequestProperty("Accept","application/json");
con.connect();
br = new BufferedReader(new InputStreamReader( con.getInputStream() ));
String str = null;
String line;
while((line = br.readLine()) != null) {
str += line;
}
System.out.println(str);
} catch (Exception e) {
e.printStackTrace();
}
Currently I am getting JSON String which i will need to parse further.目前我正在获取 JSON 字符串,我需要进一步解析它。 All I want to know is there any other way which will reduce the pain of deserialization or something more better.
我只想知道有没有其他方法可以减轻反序列化的痛苦或更好的方法。
Martin 回答的更新,Java SDK 已发布并可用于公共预览:- https://github.com/microsoftgraph/msgraph-sdk-java 。
Im not aware of any Java SDK for Microsoft Graph.我不知道有任何适用于 Microsoft Graph 的 Java SDK。 However, you can use jsonutil to generate your java objects which will reduce at least some work.
但是,您可以使用jsonutil生成 Java 对象,这至少会减少一些工作。
Edit: As mentioned by Pranay , a Java SDK is released, you should use this instead.编辑:正如Pranay所提到的,Java SDK 已发布,您应该改用它。
Another Java client for Microsoft Graph is odata-client which has support for the Graph v1.0, Beta, Graph Explorer endpoints and for Dynamics CRM and Analytics for Devops OData services. Microsoft Graph 的另一个 Java 客户端是odata-client ,它支持 Graph v1.0、Beta、Graph Explorer 端点以及 Dynamics CRM 和 Analytics for Devops OData 服务。 I was an early collaborator on the msgraph-sdk-java library and the problems there led me to create what I think is a much stronger product.
我是msgraph-sdk-java库的早期合作者,那里的问题促使我创建了我认为更强大的产品。 In particular odata-client-msgraph (and the sibling libraries)
特别是odata-client-msgraph (和兄弟库)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.