API error "Unsupported Media Type"

Using Python, I’m unable to successfully upload an image to the API. Is there sample Python code, or can someone advise on how to prepare the post request?

Did you read through this guide? https://developer.deeparteffects.com/page/guide
Please pay attention to convert the image to base64

Hi, I did read the guide, and I have been converting the image. If the request is properly formatted, the return is always

“message”: “Unsupported Media Type”

Using the sample JS code on github, this is the request that is created: https://pastebin.com/ysuDcGQV

Please let me know what I’m doing wrong.

What image type did you use?

I used a jpg with a max dimension of 1080px.

still need help on this please

bump. please, i would like to pay for this service, but i can’t even get the test plan to work.

We will send you some sample python code.

Thank you.

Here is the code I’m using now: https://gist.github.com/alexruimy/0bad1f51f2be0c8aca0f193d18b2deab

import base64
import requests
import json
from PIL import Image

UPLOAD_URL = ‘https://api.deeparteffects.com/v1/noauth/upload
STYLES_URL = ‘https://api.deeparteffects.com/v1/noauth/styles
RESULT_URL = ‘https://api.deeparteffects.com/v1/noauth/result?submissionId=%s
HEADERS = {‘content-type’: ‘application/json’, ‘x-api-key’: API_KEY}

def encode_image(image_file):
with open(image_file, “rb”) as f:
str = base64.b64encode(f.read()).decode()
return str

def upload_image(image_file, style_id, original_colors=False):

data = {
    "styleId": style_id,
    "imageBase64Encoded": encode_image(image_file)

r = requests.post(UPLOAD_URL, data=json.dumps(data), headers=HEADERS)
print(r.status_code, r.reason)

upload_image(‘image.jpg’, ‘c7984d3c-1560-11e7-afe2-06d95fe194ed’)

Thank you, this works!

Pay attention to set the content-type to ‘application/json’