创建单条业务数据
功能描述
创建单条数据。
请求方式
POST(HTTPS)
请求地址
https://www.h3yun.com/OpenApi/Invoke
参数说明
| 参数 | 参数类型 | 必须 | 说明 |
|---|---|---|---|
ActionName |
String | 是 | 调用的方法名。 |
SchemaCode |
String | 是 | 表单编码。 |
BizObject |
String | 是 | BizObject 对象的 JSON 字符串。 |
IsSubmit |
Boolean | 是 | 值为 true 时创建生效数据,false 时为草稿数据。 |
IgnoreBizObjectId |
Boolean | 否 | true: 忽略传递过来的ObjectIdfalse: 使用传递的ObjectId作为数据Id |
参数示例:
{
"ActionName": "CreateBizObject",
"SchemaCode": "D000024chuangjian",
"BizObject": "{\"CreatedBy\":\"f3f69a49-edf6-468d-9aee-8cbc82a46662\",\"OwnerId\":\"f3f69a49-edf6-468d-9aee-8cbc82a46662\",\"F0000002\":\"123\",\"F0000009\":\"03ea2021-f7d5-4001-b996-7115e63f4319;6d1af175-a49d-48ad-bc3e-52aa35bb34df;db4d0ace-9a0c-4c57-bc3d-47138856c6a6\",\"D000024Fdetail123\":[{\"zh\":\"123\"},{\"zh\":\"312\"}]}",
"IsSubmit": "true" ,
"IgnoreBizObjectId": true,
}
请求示例(C#)
string apiAddress = @"https://www.h3yun.com/OpenApi/Invoke";
HttpWebRequest request = (System.Net.HttpWebRequest)WebRequest.Create(apiAddress);
request.Method = "POST";
request.ContentType = "application/json";
// 身份认证参数
request.Headers.Add("EngineCode", "");
request.Headers.Add("EngineSecret", "");
// 参数
Dictionary<string, object> dicParams = new Dictionary<string, object>();
dicParams.Add("ActionName", "CreateBizObject");
dicParams.Add("SchemaCode", "D000024chuangjian");
// 构造业务数据
Dictionary<string, object> bizObjectData = new Dictionary<string, object>();
bizObjectData.Add("CreatedBy", "f3f69a49-edf6-468d-9aee-8cbc82a46662");
bizObjectData.Add("OwnerId", "f3f69a49-edf6-468d-9aee-8cbc82a46662");
bizObjectData.Add("F0000002", "123");
bizObjectData.Add("F0000009", "03ea2021-f7d5-4001-b996-7115e63f4319");
Dictionary<string, object> childBoData1 = new Dictionary<string, object>();
childBoData1.Add("zh", "123");
Dictionary<string, object> childBoData2 = new Dictionary<string, object>();
childBoData2.Add("zh", "124");
List<Dictionary<string, object>> childBoList = new List<Dictionary<string, object>>();
childBoList.Add(childBoData1);
childBoList.Add(childBoData2);
bizObjectData.Add("D000024Fdetail123", childBoList);
dicParams.Add("BizObject", JsonConvert.SerializeObject(bizObjectData));
dicParams.Add("IsSubmit", "true");
string jsonData = JsonConvert.SerializeObject(dicParams);
byte[] bytes;
bytes = System.Text.Encoding.UTF8.GetBytes(jsonData);
request.ContentLength = bytes.Length;
using (Stream writer = request.GetRequestStream())
{
writer.Write(bytes, 0, bytes.Length);
writer.Close();
}
string strValue = string.Empty;
using (System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse())
{
using (System.IO.Stream s = response.GetResponseStream())
{
string StrDate = string.Empty;
using (StreamReader Reader = new StreamReader(s, Encoding.UTF8))
{
while ((StrDate = Reader.ReadLine()) != null)
{
strValue += StrDate + "\r\n";
}
}
}
}
请求示例(JAVA)
Map<String, String> paramMap = new HashMap();
paramMap.put("ActionName", "CreateBizObject");
paramMap.put("SchemaCode", "D000024chuangjian");
paramMap.put("BizObject", "{\"CreatedBy\":\"f3f69a49-edf6-468d-9aee-8cbc82a46662\",\"OwnerId\":\"f3f69a49-edf6-468d-9aee-8cbc82a46662\",\"F0000002\":\"123\",\"F0000009\":\"03ea2021-f7d5-4001-b996-7115e63f4319;6d1af175-a49d-48ad-bc3e-52aa35bb34df;db4d0ace-9a0c-4c57-bc3d-47138856c6a6\",\"D000024Fdetail123\":[{\"zh\":\"123\"},{\"zh\":\"312\"}]}");
paramMap.put("IsSubmit", "true");
// 身份认证参数
Map headers = new HashMap();
headers.put("EngineCode", "");
headers.put("EngineSecret", "");
Gson gson = new Gson();
String result = HttpRequestUtil.sendPost(url, gson.toJson(paramMap), headers);
import com.google.gson.Gson;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class HttpRequestUtil {
/**
* 发送 POST 请求(JSON 格式)
* @param url 请求 URL
* @param jsonParam JSON 参数
* @param headers 请求头(键值对)
* @return 响应结果
* @throws IOException 网络异常
*/
public static String sendPost(String url, String jsonParam, Map<String, String> headers) throws IOException {
// 默认请求头
if (headers == null) {
headers = new HashMap<>();
}
// 设置默认 Content-Type 为 JSON
if (!headers.containsKey("Content-Type")) {
headers.put("Content-Type", "application/json");
}
HttpURLConnection connection = null;
try {
// 创建连接
URL requestUrl = new URL(url);
connection = (HttpURLConnection) requestUrl.openConnection();
// 设置请求方法和超时时间
connection.setRequestMethod("POST");
connection.setConnectTimeout(5000); // 连接超时时间(毫秒)
connection.setReadTimeout(5000); // 读取超时时间(毫秒)
// 设置请求头
for (Map.Entry<String, String> entry : headers.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
// 启用输出和输入
connection.setDoOutput(true);
connection.setDoInput(true);
// 写入 JSON 参数
try (OutputStream os = connection.getOutputStream()) {
byte[] input = jsonParam.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
// 获取响应
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
try (BufferedReader br = new BufferedReader(
new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
return br.lines().collect(Collectors.joining(System.lineSeparator()));
}
} else {
try (BufferedReader br = new BufferedReader(
new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8))) {
String errorResponse = br.lines().collect(Collectors.joining(System.lineSeparator()));
throw new IOException("HTTP error code: " + responseCode + ", Response: " + errorResponse);
}
}
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
// 示例调用
public static void main(String[] args) {
try {
String url = "https://infrastructure.h3yun.com/OpenApi/Invoke";
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("ActionName", "CreateBizObject");
paramMap.put("SchemaCode", "D000183140db733c569465d8205e79b37b8805d");
paramMap.put("BizObject","{\"CreatedBy\": \"f3f69a49-edf6-468d-9aee-8cbc82a46662\",\"OwnerId\": \"f3f69a49-edf6-468d-9aee-8cbc82a46662\",\"F0000001\": \"123\",\"F0000002\": \"2025-07-09\"}");
paramMap.put("IsSubmit", "true");
Map<String, String> headers = new HashMap<>();
headers.put("EngineCode", "mi4x54jcr54b0p8hwoad4wxo3");
headers.put("EngineSecret", "xxxxxxx");
String jsonParam = new Gson().toJson(paramMap);
String result = sendPost(url, jsonParam, headers);
System.out.println("Response: " + result);
} catch (IOException e) {
e.printStackTrace();
}
}
}
返回结果
| 参数 | 说明 |
|---|---|
Successful |
操作是否成功(true/false)。 |
ErrorMessage |
错误信息。 |
Logined |
未使用,可忽略。 |
ReturnData |
返回的数据。 |
DataType |
返回数据类型(默认值 0)。 |
{
"Successful": true,
"ErrorMessage": null,
"Logined": false,
"ReturnData": {
"BizObjectId": "9adb4077-00a9-4806-8abc-ec753bdab7a6",
"WorkflowInstanceId": "9b0c1c76-395d-4ff1-9807-dfcf887becb6"
},
"DataType": 0
}