Magento 2.02 - Soap API C# - 上传图片错误

时间:2016-05-06 12:46:54

标签: c# api magento soap

我有一个定制的后台系统,我试图通过Soap API来填充Magento 2.0测试台产品目录。

我在大多数属性方面取得了很大成功,但当我尝试通过调用上传base64编码图像时,我得到了

XML响应中没有给定类型的MediaGalleryEntryConverter。”

我找不到关于这个转换器是什么或应该是什么的任何信息?

我上传的文件是jpeg,我使用了这篇优秀帖子的各种排列Uploading images via the Magento SOAP API,试图获得成功。

理想情况下,我宁愿让API产品保存引用文件的外部Web链接,因为它们都已托管,甚至是本地Web服务器文件系统上的NFS安装,但我没有找到如何的示例在2.0上实现这一点。

Magento构建在Ubuntu上,我承认自己更像是Linux的Windows人员,但我确信自己做得对,包括目录权限等。

我不知道我的Magento / linux构建是否应该受到责备,还是我的代码/图像文件。

有没有人见过类似的东西,或者有任何2.0经验可以帮助我诊断这个问题?

提前致谢。

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。事实证明,我的catalogProductAttributeMediaGalleryManagementV1Create请求中的“mediaType”属性设置为“png”,但应设置为“image”。

在内部,Magento尝试将“mediaType”与可用的媒体转换器匹配,请参阅Magento \ Catalog \ Model \ Product \ Attribute \ Backend \ Media \ EntryConverterPool:getConverterByMediaType。

'sku'   => 'example-sku',
'entry' => [
    'types' => ['image',],

    //should be "image" in your case
    'mediaType' => 'image',

    'label' => 'Test Label',
    'position' => 1,
    'disabled' => false,
    'file' => './',
    'content' => [
        'base64EncodedData' => '<base64 encoded image file content>',
        'type' => 'image/png',
        'name' => 'dummy.png',
    ],
]