<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-akpqpvpbcku.n.bdcloudapi.com/s/api/ocr/invoiceCheck";
ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.POST, path);
request.setCredentials("您的 access key", "您的 secret key");
request.addHeaderParameter("Content-Type", "application/json;charset=UTF-8");
request.addQueryParameter("invoiceCode", "");
request.addQueryParameter("invoiceNumber", "");
request.addQueryParameter("checkCode", "");
request.addQueryParameter("pretaxAmount", "");
request.addQueryParameter("invoicingDate", "");
request.addQueryParameter("invoiceType", "");
request.addQueryParameter("electronicMark", "");
ApiExplorerClient client = new ApiExplorerClient(new AppSigner());
try {
ApiExplorerResponse response = client.sendRequest(request);
// 返回结果格式为Json字符串
System.out.println(response.getResult());
} catch (Exception e) {
e.printStackTrace();
}
}
}
点击复制代码
正常返回示例 {
"code": 10000,
"status": 200,
"message": "success",
"serialNo": "380884898224799744",
"data": {
"details": {
"code": "033001600211",
"number": "50843024",
"date": "2017年04月01日",
"check_code": "80167527280510503956",
"seller": "杭州爱信诺航天信息有限公司",
"seller_tax_id": "91330106555199156Q",
"buyer": "杭州天然气集团有限公司",
"buyer_tax_id": "",
"total": "10.00",
"items": [
{
"name": "服务费",
"quantity": "10.00000000",
"price": "0.94339623",
"total": "9.43"
}
]
},
"type": "10102"
}
}
失败返回示例 {
"code": 10005,
"status": 400,
"message": "无效参数(发票代码,号码,开票日期等为空或者格式错误,普票验证码为空,专票税前金额为空等不合法参数错误)",
"serialNo": "380895515304263680"
}
错误码定义 0 (0%) 好评 | 0 (0%) 中评 | 0 (0%) 差评 |