2

Using swagger I am not seeing any interface out of the box that would allow me to upload category images via API calls, in the same fashion as I can do with product images by base_64 encoding them.

Does anyone have a ready module that would allows me to upload category images? or give point me in the right direction.

6
  • did you tried this one rest/V1/products/{sku}/media.
    – inrsaurabh
    Commented May 29, 2018 at 3:36
  • this one will upload product images, I need to upload category images.
    – Timik
    Commented May 29, 2018 at 15:53
  • Yes , that was my mistake, I didn't read your question title clearly. Sorry for that.
    – inrsaurabh
    Commented May 29, 2018 at 15:56
  • no problem, thanks for participation... do you know anything about uploading category images via API?
    – Timik
    Commented May 29, 2018 at 16:05
  • No I never did this , and as you mentioned I didn't found any API for the same , if you Found any thing related to this please share.
    – inrsaurabh
    Commented Jun 1, 2018 at 14:16

1 Answer 1

4
+50

Unfortunately, there is no endpoint to upload category image, I worked on this case before, and i would like to share my solution

first of all, you need to build a custom endpoint to upload the image to this path (send the data in base64 then save it in this path)

/{magento_root}/pub/media/catalog/category

lets say your image name is your_image.jpg

after you save this image in this path, you can send the data using the standard magento endpoint

/all/V1/categories

{
  "category": {
    "parent_id": "2",
    "name": "cat_name",
    "is_active": true,
    "include_in_menu": true,
    "custom_attributes": [
      {
        "attribute_code": "image",
        "value": "your_image.jpg"
      }
    ]
  }
}
6
  • Thank you for the solution. I will need to implement it and if it works, I will give you the reps. :)
    – Timik
    Commented Jun 6, 2018 at 16:55
  • of course :), and if you need any help please let me know, the most important point for me is helping more than getting the reps. Commented Jun 6, 2018 at 17:04
  • Actually since you worked on it before, do you have the module itself? It would be super helpful if you could just post it here.
    – Timik
    Commented Jun 6, 2018 at 18:39
  • unfortunately, this was for a project not separated module , But i can give you what i did. i created new endpoint to save the category file, I sent the content of the image encoded (base64) , I decoded the content and save them in the catalog/category path with specific name (you have to insure that the name should be unique), after that i i used the standard endpoint does that make sense ? Commented Jun 7, 2018 at 15:55
  • It may take awhile until I get to this task, so awarding you with the right answer and the bounty, congrats!
    – Timik
    Commented Jun 11, 2018 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.