0

This is the api

edited

what I have to do I have to send two images with the key "bank_statement" otherwise the API will send the message "Exactly two images must be submitted." What I am doing with the request is

> myfiles = {'bank_statement': open("DOC1.jpg", 'rb'),
>                'bank_statement': open("DOC1.jpg", 'rb')}

is_extractable = requests.post(Validate, files=myfiles)

But the response is

{'timestamp': '2022-03-01 10:00:43.354058', 'message': 'Exactly two images must be submitted.', 'error': 'Bad Request', 'status': 400}

I can't figure out where is the problem is.

Anik Sen
  • 13
  • 3

2 Answers2

0

The problem is that your dictionary is not consisting of two entries, but only one.

myfiles = {'bank_statement': 'blabla', 'bank_statement': 'blablabla'}
myfiles

gives as output

{'bank_statement': 'blablabla'}

You might have to add it twice, or add a list, look at this answer.

PrinsEdje80
  • 494
  • 4
  • 8
  • Thanks a lot, yes that was the case and I have modified the code into this ``` file_list = [ ('bank_statement', ('image1.jpg', open(image1, 'rb'), 'image/png')), ('bank_statement', ('image2.jpg', open(image2, 'rb'), 'image/png')) ]``` it's working fine – Anik Sen Mar 02 '22 at 08:48
0

If you want to send two images with the one and same parameter you have create a list

 file_list = [
        ('bank_statement', ('image1.jpg', open(image1, 'rb'), 'image/png')),
        ('bank_statement', ('image2.jpg', open(image2, 'rb'), 'image/png'))
    ]

Here bank_statement is parameter and image1 on open closure is path of files I have sent.

Anik Sen
  • 13
  • 3