Hallo zusammen,
wenn ich folgendes versuche erhalte ich die Fehlermeldung am Ende dieser Nachricht. Es würde mich sehr freuen wenn jemand den Fehler findet und diesen mit mir teilt.
Vielen Dank im Voraus.
Gruß Sven
// Die media-id (POST Endpunkt: /media) habe ich bereits erstellt und ist: a2e72f4f6ac64e029886257318c702ad
String bild_upload_url = "http://shopware.none/api/_action/media/a2e72f4f6ac64e029886257318c702ad/upload?extension=jpg&fileName=product1";
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("", "",
RequestBody.create(new File("./bilder/product1.jpg"),
MediaType.parse("image/*jpg")
))
.build();
Request requestBildUpload= new Request.Builder()
.url(bild_upload_url)
.addHeader("Authorization", "Bearer " + smaApiGetToken())
.addHeader("Accept", "image/*jpg")
.post(requestBody)
.build();
Call call = client.newCall(requestBildUpload);
Response responseMediaId = call.execute();
System.out.println("API-RESPONSE:\n" + responseMediaId.body().string());
// Der komplette Response:
{"errors":[{"code":"0","status":"415","title":"Unsupported Media Type","detail":"All provided media types are unsupported. (image\/*jpg)","meta":{"trace":[{"file":"\/var\/www\/html\/sw6\/vendor\/shopware\/core\/Framework\/Api\/Response\/ResponseFactoryInterfaceValueResolver.php","line":28,"function":"getType","class":"Shopware\\Core\\Framework\\Api\\Response\\ResponseFactoryRegistry","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/symfony\/http-kernel\/Controller\/ArgumentResolver\/TraceableValueResolver.php","line":58,"function":"resolve","class":"Shopware\\Core\\Framework\\Api\\Response\\ResponseFactoryInterfaceValueResolver","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/symfony\/http-kernel\/Controller\/ArgumentResolver.php","line":59,"function":"resolve","class":"Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver\\TraceableValueResolver","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/symfony\/http-kernel\/Controller\/TraceableArgumentResolver.php","line":38,"function":"getArguments","class":"Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/symfony\/http-kernel\/HttpKernel.php","line":149,"function":"getArguments","class":"Symfony\\Component\\HttpKernel\\Controller\\TraceableArgumentResolver","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/symfony\/http-kernel\/HttpKernel.php","line":79,"function":"handleRaw","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/symfony\/http-kernel\/Kernel.php","line":195,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/symfony\/http-kernel\/HttpCache\/SubRequestHandler.php","line":85,"function":"handle","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":477,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpCache\\SubRequestHandler","type":"::"},{"file":"\/var\/www\/html\/sw6\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":267,"function":"forward","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":283,"function":"pass","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":211,"function":"invalidate","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/shopware\/core\/HttpKernel.php","line":163,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/vendor\/shopware\/core\/HttpKernel.php","line":80,"function":"doHandle","class":"Shopware\\Core\\HttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/sw6\/public\/index.php","line":77,"function":"handle","class":"Shopware\\Core\\HttpKernel","type":"-\u003E"}],"file":"\/var\/www\/html\/sw6\/vendor\/shopware\/core\/Framework\/Api\/Response\/ResponseFactoryRegistry.php","line":46}}]}