Discussions

Ask a Question
Back to All

Iam getting invalid URL error when iam trying to upload image

Hi,

Iam getting Invalid URL error, when iam trying API with http, Here is the code i made

import requests

imgLoc = r"Eric Headshot 2.png"

url = "https://api.d-id.com/images"

files = { "image": (imgLoc, open(imgLoc, "rb"), "image/png") }
headers = {
"accept": "application/json",
"authorization": "Basic MYAPIKEY"
}

response = requests.post(url, files=files, headers=headers)

print(response.text)

Here is the error log
{"kind":"InvalidFileNameError","description":"invalid file name","details":{"url":"Eric Headshot 2.png"}}