REST API for adding products

New Member
3 0 0

Hi all. Help me pls. How i can add a few images in JSON file for creating a new product via Shopify REST API? I use access token and node js. But i can add only one image.

0 Likes

Hello 
A) Use Below Format to Create a new product. because we have used this and added succesfully product with price and image also.

$data = [ "product" =>
[
    "title" => "Product Title",
    "body_html" => "description",
    "vendor" => "ABC",
    "product_type" => "New",
    "tags" => "Test",
    "published" => true,
    "images" => [
   [
   "src" => "http://example.com/test.png"
   ],
],
  "variants" => [
   [
    "price" => "150",
    "sku" => "123",
    "inventory_quantity" => 3,
    "old_inventory_quantity" => 3,
   "weight" => 2,
   "weight_unit" => "kg",
   "requires_shipping" => true

   ],
 ],

],
];



/admin/products.json', 'METHOD' => 'POST', 'DATA' => $data

B) Also Reffer the Below Link for more informations
https://help.shopify.com/en/api/reference/products/product#create-2019-07

Want to modify or incorporate custom changes on store, Hire us.
If helpful then please Like and Accept Solution .
Email: pallavi@oscprofessionals.com
Skype : oscprofessionals-87
Custom Shopify Private App | Custom Theme Development | Custom Modifications In To Shopify Theme | Digital Marketing | Site Speed Optimization | Web Development
0 Likes
New Member
3 0 0

Yes. But its method for adding one image. I need add few images.

0 Likes

You can add multiple images on this way

$data = [ "product" =>
[
    "title" => "Product Title",
    "body_html" => "description",
    "vendor" => "ABC",
    "product_type" => "New",
    "tags" => "Test",
    "published" => true,
    "images" => [
   [
   "src" => "http://example.com/test.png"
   ],
 [
   "src" => "http://example.com/test.png"
   ],
 [
   "src" => "http://example.com/test.png"
   ],
],
  "variants" => [
   [
    "price" => "150",
    "sku" => "123",
    "inventory_quantity" => 3,
    "old_inventory_quantity" => 3,
   "weight" => 2,
   "weight_unit" => "kg",
   "requires_shipping" => true

   ],
 ],

],
];

 

Want to modify or incorporate custom changes on store, Hire us.
If helpful then please Like and Accept Solution .
Email: pallavi@oscprofessionals.com
Skype : oscprofessionals-87
Custom Shopify Private App | Custom Theme Development | Custom Modifications In To Shopify Theme | Digital Marketing | Site Speed Optimization | Web Development
0 Likes
Highlighted
New Member
3 0 0

Can you write this in JSON format?

0 Likes