简体   繁体   English

通过 postman 和使用 java 的代码库调用 microsoft graph beta api

[英]calling microsoft graph beta api via postman and codebase using java

I am already aware to call microsft graph API using postman and code base for v1.0.我已经知道使用 postman 和 v1.0 的代码库调用 microsft 图 API。 Question: How to call microsoft graph beta api via postman and codebase using java for beta version.问题:如何通过 postman 和使用 java 的代码库调用 microsoft graph beta api 以获得 beta 版本。

There are lots of articles related to v1.0 but i do not find any related to beta version.有很多与 v1.0 相关的文章,但我没有找到任何与 beta 版本相关的文章。 i think, it might be possible that we can call beta version API using custom API call.我认为,我们可能可以使用自定义 API 调用来调用测试版 API。 Please suggest or share any article.请建议或分享任何文章。

Note: I know it is not recommended to use beta version API but I am working on some POC to test this注意:我知道不建议使用测试版 API 但我正在开发一些 POC 来测试它

I'm not sure if I misunderstand you.我不确定我是否误解了你。

Here's a format of graph api, and you could manage {version} to switch ' beta ' version and ' v1.0 ' version.这是图形 api 的格式,您可以管理 {version} 来切换 ' beta ' 版本和 ' v1.0 ' 版本。 Here's the description .这是描述

{HTTP method} https://graph.microsoft.com/{version}/{resource}?{query-parameters}

You can change the input choice to get different versions of one api.您可以更改输入选项以获得不同版本的 api。 在此处输入图像描述 在此处输入图像描述

=============UPDATE============ =============更新=============

//js sample call graph api
function callMSGraph(endpoint, token, callback) {
    const headers = new Headers();
    const bearer = `Bearer ${token}`;
    headers.append("Authorization", bearer);    
    const options = {
        method: "GET",
        headers: headers
    };
    fetch(endpoint, options)
        .then(response => response.json())
        .then(response => callback(response, endpoint))
        .catch(error => console.log(error))
}

java sample call graph api, code comes from this java 示例调用图 api,代码来源于

private String getUserInfoFromGraph(String accessToken) throws Exception {
        // Microsoft Graph user endpoint
        URL url = new URL(authHelper.getMsGraphEndpointHost() + "v1.0/me");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

        // Set the appropriate header fields in the request header.
        conn.setRequestProperty("Authorization", "Bearer " + accessToken);
        conn.setRequestProperty("Accept", "application/json");

        String response = HttpClientHelper.getResponseStringFromConn(conn);

        int responseCode = conn.getResponseCode();
        if(responseCode != HttpURLConnection.HTTP_OK) {
            throw new IOException(response);
        }

        JSONObject responseObject = HttpClientHelper.processResponse(responseCode, response);
        return responseObject.toString();
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM