Data API Post InsertMany - Python requests with Generator Function - chunk encoded request

Hello,

I have a folder full of json documents which I want to insert into a collection. I want to do this via data api due to network related complexity.

Based on the reference : python requests advanced topic, I am trying the below:

requests.post('http://some.url/chunked', data=gen())

Here gen() is a python generator which would chunk the post body as string (or as bytes).

I tried to do that by storing the body as file and then pass the file like object as the value to data. This is working.

But when I use the generator function, I am getting error.

I can now create a new class to generate a file like object based on generator. But I do not want to do that if generator functions are directly supported.

My questions are:

  1. Is this feature supported for Atlas Data API?
  2. If yes, is there a sample code where it is working?

Any other hints / experiences are also welcome

The error that I am getting is as below:

requests.exceptions.ConnectionError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:847)

P.S. My connections are transferred via a proxy server.