我有SugarCRM追踪帐户。我可以通过以下网址获取身份验证并获取AccessToken。

https://xxxxxxx.trial.sugarcrm.eu/rest/v10/oauth2/token


方法:开机自检
POST数据:postData:{ "grant_type":"password", "client_id":"sugar", "client_secret":"", "username":"admin", "password":"Admin123", "platform":"base" }

我用来获取AccessToken的代码

public static String getAccessToken() throws JSONException {
    HttpURLConnection connection = null;

    JSONObject requestBody = new JSONObject();
    requestBody.put("grant_type", "password");
    requestBody.put("client_id", CLIENT_ID);
    requestBody.put("client_secret", CLIENT_SECRET);
    requestBody.put("username", USERNAME);
    requestBody.put("password", PASSWORD);
    requestBody.put("platform", "base");

    try {
        URL url = new URL(HOST_URL + AUTH_URL);
        connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "application/json");
        connection.setUseCaches(false);
        connection.setDoOutput(true);
        connection.connect();

        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
        out.write(requestBody.toString());
        out.close();

        int responseCode = connection.getResponseCode();

        BufferedReader in = new BufferedReader(
                new InputStreamReader(connection.getInputStream()));
        String inputLine;
        StringBuffer response = new StringBuffer();

        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();

        JSONObject jObject = new JSONObject(response.toString());
        if(!jObject.has("access_token")){
            return null;
        }
        String accessToken = jObject.getString("access_token");

        return accessToken;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}


现在,我已经使用剩余的API从CRM中获取销售线索,但我找不到合适的方法和网址来完成此任务。

我可以从/ help看到API的其余列表,但我无法理解模块名应该是什么,我必须:record以及如何传递访问令牌进行身份验证。

谁能帮帮我吗?

最佳答案

模块名称只是您要从中获取记录的模块,因此,在这种情况下,您将需要对rest / v10 / Leads进行GET请求以获取潜在客户列表。如果要获取特定的线索,则将:record替换为线索的ID-例如:GET rest / v10 / Leads / LEAD-ID-HERE

SugarCRM的文档包含很多相关信息,这些信息可能未包含在/ help和工作示例中。

http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.8/Integration/Web_Services/v10/Endpoints/module_GET/

http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.8/Integration/Web_Services/v10/Examples/PHP/How_to_Fetch_Related_Records/

10-08 18:54