• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Shopware 6 | API | Uploading media (JPEG file) with Java OKHTTP3 outputs "Unsupported Media Type"

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

when I try the following I get the error message at the end of this message. I would be very happy if someone finds the error and shares it with me.

Many thanks in advance.
Greetings Sven






 
Saloon Keeper
Posts: 7327
170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The MIME type is called "image/jpeg", not "image/*jpg". Where did you get that?
 
Sven Auer
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:Welcome to the Ranch.

The MIME type is called "image/jpeg", not "image/*jpg". Where did you get that?



@Tim Moores Thank you for the welcome and your help. I don't remember where I got the wrong MIME type example.

I have changed the MIME type to "image/jpeg" but now I get a different "Unsupported Media Type" error:



Please help me out.

Greetings,
Sven
 
Marshal
Posts: 3827
537
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are sending image content, you will need to include a Content-Type header:
You can remove the Accept header, unless you are expecting image content to be returned.
 
Sven Auer
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:If you are sending image content, you will need to include a Content-Type header:
You can remove the Accept header, unless you are expecting image content to be returned.



The Accept header I have removed. and add the following into the Request.Builder()
.addHeader("Content-Type", "image/jpeg")

My code is also:


I get also the following error:


I hope you or someone else has another idea why it don't work.
 
Ron McLeod
Marshal
Posts: 3827
537
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know nothing about Shopware so I don't think I can help much more.

Try consulting the API document/schema to determine what the backend is actually wanting.
 
Ron McLeod
Marshal
Posts: 3827
537
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unlikely that this will resolve the problem, but maybe the message Unsupported Media Type - All provided media types are unsupported is meant to tell you that the type of content you will accept is not supported?

Try adding-back the Accept header, but with a wildcard MIME type:
 
Sven Auer
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:Unlikely that this will resolve the problem, but maybe the message Unsupported Media Type - All provided media types are unsupported is meant to tell you that the type of content you will accept is not supported?

Try adding-back the Accept header, but with a wildcard MIME type:



After add of addHeader("Accept", "*/*") I get a the following different error:


If I use the following curl command it works (it doesn't work with okhttp3) - what is wrong:

What is the code equivalent in okhttp3 for the above curl example?
 
We don't have time to be charming! Quick, read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic