I want to insert products from a csv-file into the Magento DB via the REST API. First I try to update one single product.

The product is inserted into the db but this product needs to be assigned to a category.

How do I get the productID from the result?

// post method

//Make REST request
$response = $restClient->send();

Because I have to make another call for the catagory.

$restClient->setUri($apiURL . '/products/' . $id . '/categories');
$restClient->setRawBody(); //will be filled with the categoryID

When I dump the $response, the content is protected and gives me a lot of questionmarks. When I say: var_dump($response->getBody()); The body is empty = ''

I don't think it would be necessary to make another call for getting the last product update/insert

1 Answer 1


The answer is simply in the $response.

echo $response->getBody();

$headers = $response->getHeaders();
$location = $headers->toArray();
$product_id = $location['Location'];

return $product_id;

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.