代码实例:https://ai.baidu.com/ai-doc/OCR/nk3h7xy2tDim fpsb_url As String = "https://aip.baidubce.com/rest/2.0/ocr/v1/vat_invoice?access_token={0}"
Dim data() As Byte = System.IO.File.ReadAllBytes("c:\2.png") '把文件字节流加载进来,
Dim d As String = Convert.ToBase64String(data)
Dim hc As New HttpClient(CExp(fpsb_url, AccessToken))
hc.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
hc.C
Dim zjo As New JObject
Dim dt As String = """image=" & d & """"
hc.Content = dt '提交数据并发起OA流程'
zjo = JObject.Parse(hc.GetData()) '获取流程发起ID
Output.Show(zjo.ToString)
提示图片格式错误
此主题相关图片如下:提交代码.png
[此贴子已经被作者于2024/8/16 9:30:44编辑过]
Dim fpsb_url As String = "https://aip.baidubce.com/rest/2.0/ocr/v1/vat_invoice?access_token={0}"
Dim data() As Byte = System.IO.File.ReadAllBytes("c:\2.png") '把文件字节流加载进来,
Dim d As String = Convert.ToBase64String(data)
Dim hc As New HttpClient(CExp(fpsb_url, AccessToken))
hc.ContentType = "application/x-www-form-urlencoded"
hc.FormData.Add("image",UrlEncode(d))
Dim zjo As JObject = JObject.Parse(hc.GetData()) '获取流程发起ID
[此贴子已经被作者于2024/8/16 9:53:27编辑过]
Dim fpsb_url As String = "https://aip.baidubce.com/rest/2.0/ocr/v1/vat_invoice?access_token={0}"
Dim data() As Byte = System.IO.File.ReadAllBytes("c:\2.png") '把文件字节流加载进来,
Dim d As String = Convert.ToBase64String(data)
Dim hc As New HttpClient(CExp(fpsb_url, AccessToken))
hc.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
hc.FormData.Add("image", d)
Dim zjo As New JObject
zjo = JObject.Parse(hc.GetData()) '获取接口返回数据
Output.Show(zjo.ToString)
感谢 有点蓝的指点,最终代码是个,可以正常返回数据;不能对d 进行转码
[此贴子已经被作者于2024/8/16 10:03:44编辑过]