企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## **业务保存类接口格式说明** #### 接口协议主要采用http(s),因此下面从请求头,请求体,响应体方面做出说明 * **请求头格式** |请求头标识|必填|内容|备注| | --- | --- | --- |--| |Authorization|Y|Bearer [token-data](接口访问授权.md) |遵循w3c标准| |Accept|Y| application/json;charset=utf-8|遵循w3c标准| |Content-Type|Y| application/json;charset=utf-8|遵循w3c标准| |X-ThirdSysId|Y|FW-OA|泛微OA系统标识 | * **请求体参数** |参数名|类型|必填|说明|示例| |--|--|--|--|--| |formId|string|N|URI已包含| | |operationNo|string|N|URI已包含| | |billData|JString|Y| 本参数是数组,每个数组内对象的封包结构参考:[封包结构参考](数据字典介绍.md)|| * **响应体参数** |参数名|类型|必含|说明|示例| |--|--|--|--|--| |operationResult|jobject|Y| | | |&emsp;&emsp;complextMessage|string|Y| | | |&emsp;&emsp;&emsp;&emsp;successMessages|jarray|Y|成功类消息| | |&emsp;&emsp;&emsp;&emsp;errorMessages|jarray|Y|错误类消息| | |&emsp;&emsp;&emsp;&emsp;warnMessages|jarray|Y|警告类消息| | |&emsp;&emsp;&emsp;&emsp;hasMessage|bool|Y|是否有消息| | |&emsp;&emsp;isSuccess|bool|Y|是否操作成功| | |&emsp;&emsp;srvData|any|Y|接口返回数据| 本属性是实际每个操作返回的数据,对保存操作而言,它是一个数组,其它操作返回的可能是字典,每个接口返回都可能不太一样| |&emsp;&emsp;&emsp;&emsp;[0]|jobject|Y|数组对象| | |&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;id|string|Y|保存后内码| | |&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;number|string|Y|保存后编码| | |&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;name|string|Y|保存后名称| | ## **场景示例描述** 假定现有一第三方系统(如:XXOA),需要将其系统里的【品牌】资料同步到易到家系统。现在我们在编写同步代码之前需要按以下步骤拿到几个关键信息: 1、通过[数据字典](数据字典介绍.md)功能,查找到业务对象标识,这里得到本对象的formId为:ydj_brand,同样从数据字典中得到发布的数据结构: {     "id": "",     "fname": "菲尼斯",     "fdescription": "由xx系统同步生成" } 2、通过访问授权中的步骤从待集成系统的管理员那里拿到令牌,例如令牌为(这里的令牌注意要换成目前你要集成环境下的用户令牌,不要直接拿这里的示例使用,有可能已过期): **eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImF1dGhvciI6ImxpbnVzIn0.eyJpc3MiOiJmdy5hYmNkIiwic3ViIjoiMjcwODQzNjI5MzczODg2NDY2IiwiaWF0IjoxNTU3MjE2NTY1LCJleHAiOjQwNzA4ODAwMDAsInByZWZlcnJlZF91c2VybmFtZSI6MTg1NjYyMzExNTksImNvbXBhbnlzIjpbeyJjb21wYW55SWQiOiIyNzA4NDM2MjE4MzI1Mjc4NzMiLCJjb21wYW55TmFtZSI6Iue7j-mUgOWVhjEwIiwiY29tcGFueU51bWJlciI6IjI3MDg0MzYyMTgzMjUyNzg3MyIsImFjY291bnRJZCI6IiIsImFjY291bnRTdGF0dXMiOiIifV0sImNvbXBhbnkiOiIyNzA4NDM2MjE4MzI1Mjc4NzMiLCJwcm9kdWN0IjpudWxsLCJyZWZ1c2VyaWQiOm51bGwsInJlZnNjZW5laWQiOm51bGwsImNhbGxlckNvbnRleHQiOiIiLCJ1c2VySWQiOiIyNzA4NDM2MjkzNzM4ODY0NjYiLCJyZW1vdGVVc2VySWQiOm51bGwsInVzZXJUeXBlIjowfQ.YsPtsKom5IqYVlrrY5XtIm0VBZLcbNRiPmgfF8i151skaJDA63YD0AzcZjEpCS8zRmXyZ2KKdVPhp4dDJ_lfStmsgM4ZEszA1jBbvKIzuQYaBNdM2g-uLh6IFBeQo-cE2VLtA2P7Ca1yTOTWkGfC3afeFiU-I9fAEMDPRFz6-Do** 应用标识为:**fw-oa** **有了上述信息后,只需要构建http请求了,按照上面所说的请求头、请求体的形式进行发送请求。各语言请求示例如下:** > ### ajax调用示例 ``` code区域待补充 ``` > ### nodejs调用示例 ``` code区域待补充 ``` >### C#调用示例 ``` code区域待补充 ``` >### Java调用示例 ``` package com.ydj.example.sync.ydjsync; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import java.util.List; import java.util.ArrayList; import java.util.HashMap; import javax.activation.MimetypesFileTypeMap; import com.google.gson.Gson; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.NameValuePair; import org.apache.http.StatusLine; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.protocol.HTTP; import org.apache.http.util.EntityUtils; import org.apache.log4j.Logger; @SpringBootApplication public class DemoApplication { public static void main(String[] args) {         HashMap header = new HashMap(); //这里的令牌注意要换成目前你要集成环境下的用户令牌,不要直接拿这里的示例使用,有可能已过期         header.put("Authorization","Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImF1dGhvciI6ImxpbnVzIn0.eyJpc3MiOiJmdy5hYmNkIiwic3ViIjoiMjcwODQzNjI5MzczODg2NDY2IiwiaWF0IjoxNTU5MDI1NzMxLCJleHAiOjQwNzA4ODAwMDAsInByZWZlcnJlZF91c2VybmFtZSI6MTg1NjYyMzExNTksImNvbXBhbnlzIjpbeyJjb21wYW55SWQiOiIyNzA4NDM2MjE4MzI1Mjc4NzMiLCJjb21wYW55TmFtZSI6Iue7j-mUgOWVhjEwIiwiY29tcGFueU51bWJlciI6IjI3MDg0MzYyMTgzMjUyNzg3MyIsImFjY291bnRJZCI6IjM4MTgzNzgzMzAzMzM1NTI2NiIsImFjY291bnRTdGF0dXMiOiJmcGF5YWNjb3VudF9zdGF0dXMwMSJ9XSwiY29tcGFueSI6IjI3MDg0MzYyMTgzMjUyNzg3MyIsInByb2R1Y3QiOm51bGwsInJlZnVzZXJpZCI6bnVsbCwicmVmc2NlbmVpZCI6bnVsbCwiY2FsbGVyQ29udGV4dCI6IiIsInVzZXJJZCI6IjI3MDg0MzYyOTM3Mzg4NjQ2NiIsInJlbW90ZVVzZXJJZCI6bnVsbCwidXNlclR5cGUiOjAsImFwcEtleSI6IkZXLU9BIn0.5ngc0moZRGtFjRDVTXl1pFaHshP3NVR6dNXbOMRUS2z9IF-viFFYQsP2ToJNpv84i8hx39fAEkvJy3MMHLmxV2RlWsFL915O0t1zZveM9z97LWQudqq7Rvimt6LYnor8P8nK79yXXCUAWleofu95MrVBTwPQ9cKR8lVRiFz3mIc");         header.put("Accept", "application/json;charset=utf-8");         header.put("Content-Type", "application/json;charset=utf-8"); Gson gson = new Gson();         HashMap reqParam = new HashMap<>();         HashMap billData = new HashMap<>();         billData.put("fnumber", "test100");         billData.put("fname", "test100");         billData.put("fdescription", "系统集成自动生成");         List> lstBills = new ArrayList<>();         lstBills.add(billData);         reqParam.put("billData", gson.toJson(lstBills));         String result = doPost("http://192.168.0.23:8100/bill/ydj\_dept?operationno=save", header, gson.toJson(reqParam));         HashMap jsonResult = gson.fromJson(result, HashMap.class);     } public static String doPost(String url, Map header, String jsonParams) { BufferedReader in = null; try { // 定义HttpClient HttpClient client = new DefaultHttpClient(); // 实例化HTTP方法 HttpPost request = new HttpPost(); request.setURI(new URI(url)); for (Iterator iter = header.keySet().iterator(); iter.hasNext();) { String headerName = (String) iter.next(); String value = String.valueOf(header.get(headerName)); request.addHeader(headerName, value); } //由于请求输入的参数只认json类型,因此这里的设置一定要注意,不要用错,如果误用:UrlEncodedFormEntity,将会报400错误。 StringEntity entity = new StringEntity(jsonParams); entity.setContentType("application/json"); entity.setContentEncoding("utf-8"); request.setEntity(entity); HttpResponse response = client.execute(request); int code = response.getStatusLine().getStatusCode(); if (code == 200) { // 请求成功 in = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "utf-8")); StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close(); return sb.toString(); } else { // System.out.println("状态码:" + code); return null; } } catch (Exception e) { e.printStackTrace(); return null; } } } ``` >### PHP调用示例 ``` code区域待补充 ``` >### Python调用示例 ``` code区域待补充 ```