0

I am using the http://api.carmd.com/v3.0/decode?vin= api. Whenever I hard-code the vin as per example below:

response = requests.get("http://api.carmd.com/v3.0/decode?vin=WDC0J4KB9JF321921", headers=headers)
print(response.json())

it works fine:

{'message': {'code': 0, 'message': 'ok', 'credentials': 'valid', 'version': 'v3.0.0', 'endpoint': 'decode', 'counter': 9}, 'data': {'year': 2018, 'make': 'MERCEDES-BENZ', 'model': 'GLC  COUPE', 'manufacturer': 'CHRYSLER', 'engine': 'L4, 2.0L; DOHC; 16V; DI; Turbo', 'trim': '300 4MATIC', 'transmission': 'AUTOMATIC'}}

But whenever I use the following example:

text = pytesseract.image_to_string(img)
text = remove(text)
text = str(text)
response = requests.get("http://api.carmd.com/v3.0/decode?vin={vin}".format(vin=text), headers=headers)

The following gets returned:

{'message': {'code': 1001, 'message': 'Invalid vin format', 'credentials': 'valid', 'version': 'v3.0.0', 'endpoint': 'decode', 'counter': 10}, 'data': ''}

Any ideas on why this is happening?

Update 1: "text" is being generator through OCR. It is the text being read from the image. It is being read correctly as it is generating the same VIN number as the hard coded one,

Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251
Joshua
  • 97
  • 1
  • 7
  • What is `text`? Also see https://stackoverflow.com/questions/50737866/python-requests-pass-parameter-via-get – SuperStormer Aug 12 '22 at 19:14
  • 1
    You use `pytesseract` to OCR - are you sure it's returning a valid VIN? – wkl Aug 12 '22 at 19:15
  • 1
    The obvious answer is that `text` is not, in fact, a valid VIN. And since you haven't shown us the value of `text` (which seems like a really critical piece of information to leave out of your post), there's nothing more we can say. – John Gordon Aug 12 '22 at 19:20

0 Answers0