I have an existing API that I connect to using PHP and send an image, the code looks like this...
$url = 'https://example.com/api';
$ch = \curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Subscription-Key: 345sdf4'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"fileurl\":\"" . $this->_config['server_config']['server_url'] . $my_image . "\"
}");
I am trying to convert this to Python3, I understand I need requests
so have this so far...
import requests
api_url_base = 'https://example.com/api'
headers = {'Content-Type': 'application/json',
'Subscription-Key': '345sdf4'}
But this is as far as I have got, how do I add the image? I know the absolute path of the image already