Magento 2 Unable to assign Product to category via API





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







5















There has been similar issues posted without an answer unfortunately but I am posting two ways in the API to set a category on a product both of which give different errors.



The first is using the categories repository (catalogCategoryLinkRepositoryV1)



example
In body POST



{ 
"productLink" :
{
"sku" : "TEST_SKU5",
"position" : 0,
"categoryId" : "8",
"extensionAttributes": {}

}
}


Example Response : This is the same response regardless of what category or product.



{
"message": "Could not save product "%1" with position %2 to category %3",
"parameters": [
"144",
0,
"8"
]
}


The second is setting it under custom_attribute using the product repository in either new or update calls. Both give the same result.



When setting the custom_attribute like below regardless of what sku and category I get an error. If I leave out "category_ids" it works fine but defeats the purpose of using the API to manage product import and updates.



'custom_attributes' => array(
array( 'attribute_code' => 'category_ids', 'value' => ["8"] ),
array( 'attribute_code' => 'description', 'value' => 'Simple Description' ),
array( 'attribute_code' => 'short_description', 'value' => 'Simple Short Description' ),
)


Error being the following, which is the only error I get regardless of what combination of sku and category even if the sku is not made yet and I am creating a new product..



"{"message":"URL key for specified store already exists."}"









share|improve this question
















bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • URL key for specified store already exists U can't use same Product/Category Name magento.stackexchange.com/questions/103438/… devdocs.magento.com/guides/v2.0/rest/list.html

    – Ankit Shah
    Jan 11 '17 at 1:24











  • please add your full code for create api withing curl logic also.

    – Rakesh Jesadiya
    Jan 11 '17 at 13:43













  • I can add a new category and a new sku and I get the same error.

    – Tyler
    Jan 12 '17 at 14:30











  • I've been following this issue for the same reason, may help: github.com/magento/magento2/issues/6671#issuecomment-251730504

    – thedash
    Feb 7 '17 at 16:59


















5















There has been similar issues posted without an answer unfortunately but I am posting two ways in the API to set a category on a product both of which give different errors.



The first is using the categories repository (catalogCategoryLinkRepositoryV1)



example
In body POST



{ 
"productLink" :
{
"sku" : "TEST_SKU5",
"position" : 0,
"categoryId" : "8",
"extensionAttributes": {}

}
}


Example Response : This is the same response regardless of what category or product.



{
"message": "Could not save product "%1" with position %2 to category %3",
"parameters": [
"144",
0,
"8"
]
}


The second is setting it under custom_attribute using the product repository in either new or update calls. Both give the same result.



When setting the custom_attribute like below regardless of what sku and category I get an error. If I leave out "category_ids" it works fine but defeats the purpose of using the API to manage product import and updates.



'custom_attributes' => array(
array( 'attribute_code' => 'category_ids', 'value' => ["8"] ),
array( 'attribute_code' => 'description', 'value' => 'Simple Description' ),
array( 'attribute_code' => 'short_description', 'value' => 'Simple Short Description' ),
)


Error being the following, which is the only error I get regardless of what combination of sku and category even if the sku is not made yet and I am creating a new product..



"{"message":"URL key for specified store already exists."}"









share|improve this question
















bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • URL key for specified store already exists U can't use same Product/Category Name magento.stackexchange.com/questions/103438/… devdocs.magento.com/guides/v2.0/rest/list.html

    – Ankit Shah
    Jan 11 '17 at 1:24











  • please add your full code for create api withing curl logic also.

    – Rakesh Jesadiya
    Jan 11 '17 at 13:43













  • I can add a new category and a new sku and I get the same error.

    – Tyler
    Jan 12 '17 at 14:30











  • I've been following this issue for the same reason, may help: github.com/magento/magento2/issues/6671#issuecomment-251730504

    – thedash
    Feb 7 '17 at 16:59














5












5








5








There has been similar issues posted without an answer unfortunately but I am posting two ways in the API to set a category on a product both of which give different errors.



The first is using the categories repository (catalogCategoryLinkRepositoryV1)



example
In body POST



{ 
"productLink" :
{
"sku" : "TEST_SKU5",
"position" : 0,
"categoryId" : "8",
"extensionAttributes": {}

}
}


Example Response : This is the same response regardless of what category or product.



{
"message": "Could not save product "%1" with position %2 to category %3",
"parameters": [
"144",
0,
"8"
]
}


The second is setting it under custom_attribute using the product repository in either new or update calls. Both give the same result.



When setting the custom_attribute like below regardless of what sku and category I get an error. If I leave out "category_ids" it works fine but defeats the purpose of using the API to manage product import and updates.



'custom_attributes' => array(
array( 'attribute_code' => 'category_ids', 'value' => ["8"] ),
array( 'attribute_code' => 'description', 'value' => 'Simple Description' ),
array( 'attribute_code' => 'short_description', 'value' => 'Simple Short Description' ),
)


Error being the following, which is the only error I get regardless of what combination of sku and category even if the sku is not made yet and I am creating a new product..



"{"message":"URL key for specified store already exists."}"









share|improve this question
















There has been similar issues posted without an answer unfortunately but I am posting two ways in the API to set a category on a product both of which give different errors.



The first is using the categories repository (catalogCategoryLinkRepositoryV1)



example
In body POST



{ 
"productLink" :
{
"sku" : "TEST_SKU5",
"position" : 0,
"categoryId" : "8",
"extensionAttributes": {}

}
}


Example Response : This is the same response regardless of what category or product.



{
"message": "Could not save product "%1" with position %2 to category %3",
"parameters": [
"144",
0,
"8"
]
}


The second is setting it under custom_attribute using the product repository in either new or update calls. Both give the same result.



When setting the custom_attribute like below regardless of what sku and category I get an error. If I leave out "category_ids" it works fine but defeats the purpose of using the API to manage product import and updates.



'custom_attributes' => array(
array( 'attribute_code' => 'category_ids', 'value' => ["8"] ),
array( 'attribute_code' => 'description', 'value' => 'Simple Description' ),
array( 'attribute_code' => 'short_description', 'value' => 'Simple Short Description' ),
)


Error being the following, which is the only error I get regardless of what combination of sku and category even if the sku is not made yet and I am creating a new product..



"{"message":"URL key for specified store already exists."}"






magento2 api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 19 '17 at 15:58







Tyler

















asked Dec 27 '16 at 15:50









TylerTyler

133314




133314





bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • URL key for specified store already exists U can't use same Product/Category Name magento.stackexchange.com/questions/103438/… devdocs.magento.com/guides/v2.0/rest/list.html

    – Ankit Shah
    Jan 11 '17 at 1:24











  • please add your full code for create api withing curl logic also.

    – Rakesh Jesadiya
    Jan 11 '17 at 13:43













  • I can add a new category and a new sku and I get the same error.

    – Tyler
    Jan 12 '17 at 14:30











  • I've been following this issue for the same reason, may help: github.com/magento/magento2/issues/6671#issuecomment-251730504

    – thedash
    Feb 7 '17 at 16:59



















  • URL key for specified store already exists U can't use same Product/Category Name magento.stackexchange.com/questions/103438/… devdocs.magento.com/guides/v2.0/rest/list.html

    – Ankit Shah
    Jan 11 '17 at 1:24











  • please add your full code for create api withing curl logic also.

    – Rakesh Jesadiya
    Jan 11 '17 at 13:43













  • I can add a new category and a new sku and I get the same error.

    – Tyler
    Jan 12 '17 at 14:30











  • I've been following this issue for the same reason, may help: github.com/magento/magento2/issues/6671#issuecomment-251730504

    – thedash
    Feb 7 '17 at 16:59

















URL key for specified store already exists U can't use same Product/Category Name magento.stackexchange.com/questions/103438/… devdocs.magento.com/guides/v2.0/rest/list.html

– Ankit Shah
Jan 11 '17 at 1:24





URL key for specified store already exists U can't use same Product/Category Name magento.stackexchange.com/questions/103438/… devdocs.magento.com/guides/v2.0/rest/list.html

– Ankit Shah
Jan 11 '17 at 1:24













please add your full code for create api withing curl logic also.

– Rakesh Jesadiya
Jan 11 '17 at 13:43







please add your full code for create api withing curl logic also.

– Rakesh Jesadiya
Jan 11 '17 at 13:43















I can add a new category and a new sku and I get the same error.

– Tyler
Jan 12 '17 at 14:30





I can add a new category and a new sku and I get the same error.

– Tyler
Jan 12 '17 at 14:30













I've been following this issue for the same reason, may help: github.com/magento/magento2/issues/6671#issuecomment-251730504

– thedash
Feb 7 '17 at 16:59





I've been following this issue for the same reason, may help: github.com/magento/magento2/issues/6671#issuecomment-251730504

– thedash
Feb 7 '17 at 16:59










1 Answer
1






active

oldest

votes


















0














You have to check below code for set product in category with position,



   <?php            
$url="http://127.0.0.1/magento2.1/"; //your custom site url...
$token_url=$url."rest/V1/integration/admin/token";

//Below 9 is category id....
$product_url=$url. "rest/V1/categories/9/products";
$username="admin";
$password="admin123";
//Authentication rest API magento2, get access token
$ch = curl_init();
$data = array("username" => $username, "password" => $password);
$data_string = json_encode($data);

$ch = curl_init($token_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);
$adminToken= json_decode($token);

//9 is category id...
$sampleProductData = array(
"sku" => "24-MB01",
"position" => 5,
"category_id" => "9",
"extension_attributes" => array()
);
$categoryData = json_encode(array('productLink' => $sampleProductData));

$setHaders = array('Content-Type:application/json','Authorization:Bearer '.$adminToken);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $product_url);
curl_setopt($ch,CURLOPT_POSTFIELDS, $categoryData);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, $setHaders);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);





share|improve this answer
























  • hi rakesh, Please open once this url. and place order with cod. place order is not working. depoto.com its urgent to me. sorry for asking here

    – Teja Bhagavan Kollepara
    Jan 12 '17 at 12:29













  • Look at your array for adding to category and then look at mine, they are almost identical. categoryId and category_id as the key result in the same error. Setting a different position doesn't change that.

    – Tyler
    Jan 12 '17 at 14:29











  • You can just try with above solutions. I have test it.

    – Rakesh Jesadiya
    Jan 12 '17 at 14:44











  • This is the result of using your code : "{"message":"Could not save product "%1" with position %2 to category %3","parameters":["237",5,"17"]}"

    – Tyler
    Jan 12 '17 at 16:07











  • Have you checked category with id 9 exist or not for your admin?

    – Rakesh Jesadiya
    Jan 12 '17 at 16:09












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f152057%2fmagento-2-unable-to-assign-product-to-category-via-api%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You have to check below code for set product in category with position,



   <?php            
$url="http://127.0.0.1/magento2.1/"; //your custom site url...
$token_url=$url."rest/V1/integration/admin/token";

//Below 9 is category id....
$product_url=$url. "rest/V1/categories/9/products";
$username="admin";
$password="admin123";
//Authentication rest API magento2, get access token
$ch = curl_init();
$data = array("username" => $username, "password" => $password);
$data_string = json_encode($data);

$ch = curl_init($token_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);
$adminToken= json_decode($token);

//9 is category id...
$sampleProductData = array(
"sku" => "24-MB01",
"position" => 5,
"category_id" => "9",
"extension_attributes" => array()
);
$categoryData = json_encode(array('productLink' => $sampleProductData));

$setHaders = array('Content-Type:application/json','Authorization:Bearer '.$adminToken);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $product_url);
curl_setopt($ch,CURLOPT_POSTFIELDS, $categoryData);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, $setHaders);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);





share|improve this answer
























  • hi rakesh, Please open once this url. and place order with cod. place order is not working. depoto.com its urgent to me. sorry for asking here

    – Teja Bhagavan Kollepara
    Jan 12 '17 at 12:29













  • Look at your array for adding to category and then look at mine, they are almost identical. categoryId and category_id as the key result in the same error. Setting a different position doesn't change that.

    – Tyler
    Jan 12 '17 at 14:29











  • You can just try with above solutions. I have test it.

    – Rakesh Jesadiya
    Jan 12 '17 at 14:44











  • This is the result of using your code : "{"message":"Could not save product "%1" with position %2 to category %3","parameters":["237",5,"17"]}"

    – Tyler
    Jan 12 '17 at 16:07











  • Have you checked category with id 9 exist or not for your admin?

    – Rakesh Jesadiya
    Jan 12 '17 at 16:09
















0














You have to check below code for set product in category with position,



   <?php            
$url="http://127.0.0.1/magento2.1/"; //your custom site url...
$token_url=$url."rest/V1/integration/admin/token";

//Below 9 is category id....
$product_url=$url. "rest/V1/categories/9/products";
$username="admin";
$password="admin123";
//Authentication rest API magento2, get access token
$ch = curl_init();
$data = array("username" => $username, "password" => $password);
$data_string = json_encode($data);

$ch = curl_init($token_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);
$adminToken= json_decode($token);

//9 is category id...
$sampleProductData = array(
"sku" => "24-MB01",
"position" => 5,
"category_id" => "9",
"extension_attributes" => array()
);
$categoryData = json_encode(array('productLink' => $sampleProductData));

$setHaders = array('Content-Type:application/json','Authorization:Bearer '.$adminToken);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $product_url);
curl_setopt($ch,CURLOPT_POSTFIELDS, $categoryData);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, $setHaders);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);





share|improve this answer
























  • hi rakesh, Please open once this url. and place order with cod. place order is not working. depoto.com its urgent to me. sorry for asking here

    – Teja Bhagavan Kollepara
    Jan 12 '17 at 12:29













  • Look at your array for adding to category and then look at mine, they are almost identical. categoryId and category_id as the key result in the same error. Setting a different position doesn't change that.

    – Tyler
    Jan 12 '17 at 14:29











  • You can just try with above solutions. I have test it.

    – Rakesh Jesadiya
    Jan 12 '17 at 14:44











  • This is the result of using your code : "{"message":"Could not save product "%1" with position %2 to category %3","parameters":["237",5,"17"]}"

    – Tyler
    Jan 12 '17 at 16:07











  • Have you checked category with id 9 exist or not for your admin?

    – Rakesh Jesadiya
    Jan 12 '17 at 16:09














0












0








0







You have to check below code for set product in category with position,



   <?php            
$url="http://127.0.0.1/magento2.1/"; //your custom site url...
$token_url=$url."rest/V1/integration/admin/token";

//Below 9 is category id....
$product_url=$url. "rest/V1/categories/9/products";
$username="admin";
$password="admin123";
//Authentication rest API magento2, get access token
$ch = curl_init();
$data = array("username" => $username, "password" => $password);
$data_string = json_encode($data);

$ch = curl_init($token_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);
$adminToken= json_decode($token);

//9 is category id...
$sampleProductData = array(
"sku" => "24-MB01",
"position" => 5,
"category_id" => "9",
"extension_attributes" => array()
);
$categoryData = json_encode(array('productLink' => $sampleProductData));

$setHaders = array('Content-Type:application/json','Authorization:Bearer '.$adminToken);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $product_url);
curl_setopt($ch,CURLOPT_POSTFIELDS, $categoryData);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, $setHaders);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);





share|improve this answer













You have to check below code for set product in category with position,



   <?php            
$url="http://127.0.0.1/magento2.1/"; //your custom site url...
$token_url=$url."rest/V1/integration/admin/token";

//Below 9 is category id....
$product_url=$url. "rest/V1/categories/9/products";
$username="admin";
$password="admin123";
//Authentication rest API magento2, get access token
$ch = curl_init();
$data = array("username" => $username, "password" => $password);
$data_string = json_encode($data);

$ch = curl_init($token_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);
$adminToken= json_decode($token);

//9 is category id...
$sampleProductData = array(
"sku" => "24-MB01",
"position" => 5,
"category_id" => "9",
"extension_attributes" => array()
);
$categoryData = json_encode(array('productLink' => $sampleProductData));

$setHaders = array('Content-Type:application/json','Authorization:Bearer '.$adminToken);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $product_url);
curl_setopt($ch,CURLOPT_POSTFIELDS, $categoryData);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, $setHaders);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 12 '17 at 12:27









Rakesh JesadiyaRakesh Jesadiya

30.5k1577126




30.5k1577126













  • hi rakesh, Please open once this url. and place order with cod. place order is not working. depoto.com its urgent to me. sorry for asking here

    – Teja Bhagavan Kollepara
    Jan 12 '17 at 12:29













  • Look at your array for adding to category and then look at mine, they are almost identical. categoryId and category_id as the key result in the same error. Setting a different position doesn't change that.

    – Tyler
    Jan 12 '17 at 14:29











  • You can just try with above solutions. I have test it.

    – Rakesh Jesadiya
    Jan 12 '17 at 14:44











  • This is the result of using your code : "{"message":"Could not save product "%1" with position %2 to category %3","parameters":["237",5,"17"]}"

    – Tyler
    Jan 12 '17 at 16:07











  • Have you checked category with id 9 exist or not for your admin?

    – Rakesh Jesadiya
    Jan 12 '17 at 16:09



















  • hi rakesh, Please open once this url. and place order with cod. place order is not working. depoto.com its urgent to me. sorry for asking here

    – Teja Bhagavan Kollepara
    Jan 12 '17 at 12:29













  • Look at your array for adding to category and then look at mine, they are almost identical. categoryId and category_id as the key result in the same error. Setting a different position doesn't change that.

    – Tyler
    Jan 12 '17 at 14:29











  • You can just try with above solutions. I have test it.

    – Rakesh Jesadiya
    Jan 12 '17 at 14:44











  • This is the result of using your code : "{"message":"Could not save product "%1" with position %2 to category %3","parameters":["237",5,"17"]}"

    – Tyler
    Jan 12 '17 at 16:07











  • Have you checked category with id 9 exist or not for your admin?

    – Rakesh Jesadiya
    Jan 12 '17 at 16:09

















hi rakesh, Please open once this url. and place order with cod. place order is not working. depoto.com its urgent to me. sorry for asking here

– Teja Bhagavan Kollepara
Jan 12 '17 at 12:29







hi rakesh, Please open once this url. and place order with cod. place order is not working. depoto.com its urgent to me. sorry for asking here

– Teja Bhagavan Kollepara
Jan 12 '17 at 12:29















Look at your array for adding to category and then look at mine, they are almost identical. categoryId and category_id as the key result in the same error. Setting a different position doesn't change that.

– Tyler
Jan 12 '17 at 14:29





Look at your array for adding to category and then look at mine, they are almost identical. categoryId and category_id as the key result in the same error. Setting a different position doesn't change that.

– Tyler
Jan 12 '17 at 14:29













You can just try with above solutions. I have test it.

– Rakesh Jesadiya
Jan 12 '17 at 14:44





You can just try with above solutions. I have test it.

– Rakesh Jesadiya
Jan 12 '17 at 14:44













This is the result of using your code : "{"message":"Could not save product "%1" with position %2 to category %3","parameters":["237",5,"17"]}"

– Tyler
Jan 12 '17 at 16:07





This is the result of using your code : "{"message":"Could not save product "%1" with position %2 to category %3","parameters":["237",5,"17"]}"

– Tyler
Jan 12 '17 at 16:07













Have you checked category with id 9 exist or not for your admin?

– Rakesh Jesadiya
Jan 12 '17 at 16:09





Have you checked category with id 9 exist or not for your admin?

– Rakesh Jesadiya
Jan 12 '17 at 16:09


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f152057%2fmagento-2-unable-to-assign-product-to-category-via-api%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

What other Star Trek series did the main TNG cast show up in?

Berlina muro

Berlina aerponto