首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bitrix调用api rest java

Bitrix调用api rest java
EN

Stack Overflow用户
提问于 2017-09-28 14:55:18
回答 3查看 1.7K关注 0票数 0

所有人!嗨。

我是使用bitrix24的新手。现在,我正在开发通过调用rest api将数据从第三个应用程序发送到bitrix CRM。

那么,您是否可以帮助了解: bitrix是否支持使用java代码调用rest api?如果是,请帮我举一些例子。

非常感谢。

EN

回答 3

Stack Overflow用户

发布于 2018-07-11 20:59:22

此示例将新的自定义字段添加到公司对象

代码语言:javascript
复制
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost("https://xxxx.bitrix24.de/rest/1/xxxxx/crm.company.userfield.add/");

//@see bitrix documentation for more details https://training.bitrix24.com/rest_help/crm/contacts/crm_contact_userfield_add.php
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("fields[FIELD_NAME": "MY_STRING" };
params.add(new BasicNameValuePair("fields[EDIT_FORM_LABEL": "My string" };
params.add(new BasicNameValuePair("fields[LIST_COLUMN_LABEL": "My string" };
params.add(new BasicNameValuePair("fields[USER_TYPE_ID": "string" };
params.add(new BasicNameValuePair("fields[XML_ID": "MY_STRING" };

httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));

//Execute and get the response.
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();

if (entity != null) {
    InputStream instream = entity.getContent();
    try {
        // do something useful
    } finally {
        instream.close();
    }
}
票数 1
EN

Stack Overflow用户

发布于 2017-10-20 00:21:10

Bitrix接受rest请求,从哪里发出请求并不重要。

他们有这个文档,显示了所有接受的“操作”:https://training.bitrix24.com/rest_help/index.php

和bitrix有一个你可以轻松设置的wehbook,在下面的链接中你将看到如何设置,但是示例代码是用PHP编写的,但是你可以使用java和一些库(ssl的java.net.HttpURLConnection或javax.net.ssl.HttpsURLConnection )发出相同类型的请求:

https://www.bitrix24.com/about/blogs/updates/fast-bitrix24-integration-webhook-street-magic.php

票数 0
EN

Stack Overflow用户

发布于 2020-01-08 13:18:23

您可以使用bitrix24-java-api。请在github上查找此库的最新版本。

添加Maven依赖项

代码语言:javascript
复制
<repositories>
  <repository>
     <id>bitrix24-java-api-mvn-repo</id>
         <url>https://raw.github.com/JavaStream/bitrix24-java-api/mvn-repo/</url>
         <snapshots>
             <enabled>true</enabled>
             <updatePolicy>always</updatePolicy>
         </snapshots>
   </repository>
</repositories>

<dependency>
    <groupId>com.javastream</groupId>
    <artifactId>java-bitrix24-api</artifactId>
    <version>0.8-SNAPSHOT</version>
 </dependency>

在你的项目中初始化客户端。您需要插入Webhook令牌和bitrix-account。

客户端=新客户端(“token”,"your-account.bitrix24.ru",rest_id);

代码语言:javascript
复制
For example, working with Lead entity:

    // Create and save new Lead
    Lead lead = new Lead();         
    lead.add_title("Torrentino");
    client.getLeadService().addNewLead(lead); 

   // Get lead by ID = 4 
   Lead lead = client.getLeadService().getLeadById(4);

   // Delete lead by ID = 4
   client.getLeadService().deleteLeadById(4);

   // Update Lead 
   Lead lead = client.getLeadService().getLeadById(4);

  // Set new values for Simple fields (like String) 
  lead.setNAME("Albert");
  lead.setLAST_NAME("Shtein");
  lead.setADDRESS("West Olympic Boulevard Apt. 100");
  lead.setCOMMENTS("Interested in price");
  lead.setSTATUS_ID(StatusID_type.NEW.getCode());
  lead.setCURRENCY_ID(CurrencyID_type.EUR.getCode());
  lead.setSOURCE_ID(SourceID_type.RECOMMENDATION.getCode());

  // In multiple fields containing lists, the data is entered differently (for example, Phone, Email, Website, IM). For example, I change the first website
  Website website = lead.getWEB().get(0);
  website.setVALUE("www.albert-best.org");
  website.setVALUE_TYPE(Website_type.OTHER.getCode());
  List<Website> websitList = new ArrayList<>();
  websitList.add(website);
  lead.setWEB(websitList);
  client.getLeadService().updateLead(lead); 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46462753

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档