'I am working on pen to print Handwriting OCR using API
I am working to pen to print Handwriting ocr ap when I testing my api in postman it's work but when I try to use request and insert image in payload I get the errors said:
{"error":"General Exception:{} has type dict, but expected one of: bytes, unicode","log":["session null","srcUrl null","includeSubScan null","Execution Time:0.0003867149353027344"],"result":"0","time":0.0003867149353027344}
my code is :
import requests
import base64
import pdb
url = "https://pen-to-print-handwriting-ocr.p.rapidapi.com/recognize/"
file = 'G:\\Projects\Python&AI\\handwritting\\testimage.jpg'
with open(file, "rb") as image_file:
payload = f"-----011000010111000001101001\rContent - Disposition: form - data;name " \
f"=\"srcImg\"\r\r\r-----011000010111000001101001\rContent - Disposition: form - data;name " \
f"=\"Session\"\r\rstring\r-----011000010111000001101001 - -\r\r "
print(payload)
headers = {
"content-type": "multipart/form-data; boundary=---011000010111000001101001",
"X-RapidAPI-Host": "pen-to-print-handwriting-ocr.p.rapidapi.com",
"X-RapidAPI-Key": "APIKEY"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
