产品详情
API参数 通用发票识别 调用地址: http,https://invoice.api.bdymkt.com/s/api/ocr/invoice 请求方式: POST 支持格式: application/json;charset=UTF-8 调用工具: 去调试 请求参数(Headers) 请求参数(Query)
- 名称
- 类型
- 是否必须
- 示例值
- 描述
- imageUrl
- string
- false
- null
- 图片的URL地址;支持PNG、JPG、JPEG,暂不支持GIF格式;优先使用该参数
- imageBase64
- string
- false
- null
- 图片base64编码(包含data:image/png;base64,)
<dependency>
<groupId>com.baidubce</groupId>
<artifactId>api-explorer-sdk</artifactId>
<version>1.0.0</version>
</dependency>
import com.baidubce.http.ApiExplorerClient;
import com.baidubce.http.AppSigner;
import com.baidubce.http.HttpMethodName;
import com.baidubce.model.ApiExplorerRequest;
import com.baidubce.model.ApiExplorerResponse;
// 通用发票识别 Java示例代码
public class RequestDemo {
public static void main(String[] args) {
String path = "https://gwgp-dmgjrjt5y5f.n.bdcloudapi.com/s/api/ocr/invoice";
ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.POST, path);
request.setCredentials("您的 access key", "您的 secret key");
request.addHeaderParameter("Content-Type", "application/json;charset=UTF-8");
request.addQueryParameter("imageUrl", "");
request.addQueryParameter("imageBase64", "");
ApiExplorerClient client = new ApiExplorerClient(new AppSigner());
try {
ApiExplorerResponse response = client.sendRequest(request);
// 返回结果格式为Json字符串
System.out.println(response.getResult());
} catch (Exception e) {
e.printStackTrace();
}
}
}
点击复制代码
正常返回示例 {
"status": 200,
"message": "success",
"serialNo": "378743804296953856",
"data": {
"details": {
"code": "044002000104",
"number": "03483370",
"code_confirm": "044002000104",
"number_confirm": "03483370",
"date": "2021年02月21日",
"check_code": "56890417283003853004",
"seller": "广州市番禺区大石毛家湾湘菜馆",
"seller_tax_id": "92440101L06749998Y",
"buyer": "深圳市悦保科技有限公司",
"buyer_tax_id": "91440300MA5DP3C76P",
"category": null,
"total": "132.00",
"kind": "餐饮",
"province": "广东省",
"city": "",
"company_seal": "1",
"service_name": "餐饮服务",
"item_names": "*餐饮服务*餐费",
"title": null,
"items": [
{
"name": "*餐饮服务*餐费",
"quantity": null,
"price": null,
"total": "130.69"
}
]
},
"type": "10101"
}
}
失败返回示例 {
"serialNo": "343839777521696229",
"message": "错误描述",
"status": 400
}
错误码定义 - code
- message
- status
- 描述
- 0
- --
- 200
- 请求成功
- --
- --
- 400
- 业务异常,具体message提示
