Adding images with REST API
-
I’m trying to create a product with multiple high res images but I’m encountering a lot of issues. First I tried to just add all the images at the same time in the proper format but the Woocommerce httpClient kept timing out. Even after I added ‘timeout’ => 0 when i create the client, it was getting through around 3 images then just throwing a json syntax error or something (format/syntax is fine I’ve triple checked with the docs).
Adding links individually works (so all the links are fine) but how can I add images to the product gallery one at a time so it doesn’t complain? I’ve tried something like this:
$data['images'][0] = $images[0]; $wc->post('products',$data) for($i = 1; $i < count($images); $i++) $wc->put('products/'.$id, [ 'images' => [ $i => $images[$i] ] ]);
But it just replaces the one image each put and I’m left with the last image in the array.
- The topic ‘Adding images with REST API’ is closed to new replies.