开发者社区> 问答> 正文

从SUGARCRM查询数据

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

谁能帮帮我吗?

展开
收起
游客ufivfoddcd53c 2020-01-04 15:18:13 917 0
1 条回答
写回答
取消 提交回答
  • 您需要将检索到的令牌包含在OAuth-Token标头中以用于后续请求,然后仅将模块名称用作端点,即您的情况:“ rest / v10 / Leads”,并调用GET方法以检索它们。试试类似的东西:

    String token = getAccessToken();
        HttpURLConnection connection = null;
        try {
    
            URL url = new URL(HOST_URL + "/rest/v10/Leads");
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("OAuth-Token", token);
            connection.setUseCaches(false);
            connection.setDoOutput(true);
            connection.connect();
    
    
            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());
    
            System.out.println(jObject);
    
    
        } catch (Exception e) {
            e.printStackTrace();
        }
    
    

    如果您想将其过滤为特定的ID以减少返回的数据量,则可以在模块名称后指定它,即“ rest / v10 / Leads / {Id}”

    2020-01-04 15:18:40
    赞同 展开评论 打赏
问答分类:
API
问答地址:
问答排行榜
最热
最新

相关电子书

更多
RowKey与索引设计:技巧与案例分析 立即下载
基于HBase的海量数据查询与检索解析_游骐_202105_v3 立即下载
低代码开发师(初级)实战教程 立即下载