Magento 2 - Really need help “Server can´t understand Content-Type HTTP header…”Magento 2 - Construct a HTTP Post REST APIMagento REST API / Apache and “Content-Type header is empty”Magento 2 Custom Web Api callNeed Help To Connect Magento Rest Api using curlMagento 2 Rest API - how do I add values to dropdown product attributeUnable to create customer using curl commandMagento 2.2 - I need little help with install one moduleoauth/token/request not getting parameter from thirdparty applicationMagento 2.2.2 REST API - I need to change the customer password using REST APIConfigurable product lose image role while link simple productAdd configure product in Cart using Magento 2 API facing an issue

Is it possible to determine the symmetric encryption method used by output size?

Size of electromagnet needed to replicate Earth's magnetic field

Are Boeing 737-800’s grounded?

Is the 5 MB static resource size limit 5,242,880 bytes or 5,000,000 bytes?

Which big number is bigger?

What happened to Captain America in Endgame?

What is the relationship between spectral sequences and obstruction theory?

Is there a way to get a compiler for the original B programming language?

Noun clause (singular all the time?)

Packing rectangles: Does rotation ever help?

Rivers without rain

Don’t seats that recline flat defeat the purpose of having seatbelts?

Unexpected email from Yorkshire Bank

Error message with tabularx

Exchange,swap or switch

Will tsunami waves travel forever if there was no land?

Does Gita support doctrine of eternal cycle of birth and death for evil people?

Was there a shared-world project before "Thieves World"?

Why isn't the definition of absolute value applied when squaring a radical containing a variable?

Please, smoke with good manners

How to have a sharp product image?

What's the polite way to say "I need to urinate"?

US visa is under administrative processing, I need the passport back ASAP

Critique of timeline aesthetic



Magento 2 - Really need help “Server can´t understand Content-Type HTTP header…”


Magento 2 - Construct a HTTP Post REST APIMagento REST API / Apache and “Content-Type header is empty”Magento 2 Custom Web Api callNeed Help To Connect Magento Rest Api using curlMagento 2 Rest API - how do I add values to dropdown product attributeUnable to create customer using curl commandMagento 2.2 - I need little help with install one moduleoauth/token/request not getting parameter from thirdparty applicationMagento 2.2.2 REST API - I need to change the customer password using REST APIConfigurable product lose image role while link simple productAdd configure product in Cart using Magento 2 API facing an issue






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








1















I´m a newbie with Magento 2 and the REST API so I need a little help with this code because I tried many things and the result is always the same.



$adminUrl='http://mylink.com/index.php/rest/V1/integration/admin/token';
$ch = curl_init();
$data = array("username" => "user", "password" => "password");
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
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);
$token= json_decode($token);

$headers = array("Authorization: Bearer $token");

$requestUrl='http://mylink.com/magento2/index.php/rest/V1/products';

$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);

$post ='
"product":
"sku": "0010001234",
"name": "PRODUCTO DE PRUEBA",
"attributeSetId": "4",
"price": 20,
"status": 1,
"visibility": 4,
"typeId": "virtual",
"weight": 0,
"extensionAttributes":
"stockItem":

"stockId": 1,
"qty": 20,
"isInStock": true,
"isQtyDecimal": false,
"useConfigMinQty": true,
"minQty": 0,
"useConfigMinSaleQty": 0,
"minSaleQty": 0,
"useConfigMaxSaleQty": true,
"maxSaleQty": 0,
"useConfigBackorders": false,
"backorders": 0,
"useConfigNotifyStockQty": true,
"notifyStockQty": 20,
"useConfigQtyIncrements": false,
"qtyIncrements": 0,
"useConfigEnableQtyInc": false,
"enableQtyIncrements": false,
"useConfigManageStock": true,
"manageStock": true,
"lowStockDate": "string",
"isDecimalDivided": true,
"stockStatusChangedAuto": 0,
"extensionAttributes":

,
"options": [],
"tierPrices": [],
"customAttributes": []
,
"saveOptions": true
';

$options = array(
CURLOPT_VERBOSE=>0,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_USERAGENT=>"Mozilla/4.0 (compatible;)",
CURLOPT_POST=>true,
CURLOPT_POSTFIELDS=>$post
);

curl_setopt_array($ch, $options);
$result = curl_exec($ch);
$result= json_decode($result);
print_r($result);
return $result;


after run this I recieved the following message:



stdClass Object ( [message] => Server cannot understand Content-Type HTTP header media type application/x-www-form-urlencoded )


honestly I have many days trying to resolve this issue but not luck until now. So that is why I am asking for help now.



So thank you in advance for any help.










share|improve this question
















bumped to the homepage by Community 12 mins ago


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















  • check this magento.stackexchange.com/q/132149/20064

    – Piyush
    Jan 31 '18 at 16:42

















1















I´m a newbie with Magento 2 and the REST API so I need a little help with this code because I tried many things and the result is always the same.



$adminUrl='http://mylink.com/index.php/rest/V1/integration/admin/token';
$ch = curl_init();
$data = array("username" => "user", "password" => "password");
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
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);
$token= json_decode($token);

$headers = array("Authorization: Bearer $token");

$requestUrl='http://mylink.com/magento2/index.php/rest/V1/products';

$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);

$post ='
"product":
"sku": "0010001234",
"name": "PRODUCTO DE PRUEBA",
"attributeSetId": "4",
"price": 20,
"status": 1,
"visibility": 4,
"typeId": "virtual",
"weight": 0,
"extensionAttributes":
"stockItem":

"stockId": 1,
"qty": 20,
"isInStock": true,
"isQtyDecimal": false,
"useConfigMinQty": true,
"minQty": 0,
"useConfigMinSaleQty": 0,
"minSaleQty": 0,
"useConfigMaxSaleQty": true,
"maxSaleQty": 0,
"useConfigBackorders": false,
"backorders": 0,
"useConfigNotifyStockQty": true,
"notifyStockQty": 20,
"useConfigQtyIncrements": false,
"qtyIncrements": 0,
"useConfigEnableQtyInc": false,
"enableQtyIncrements": false,
"useConfigManageStock": true,
"manageStock": true,
"lowStockDate": "string",
"isDecimalDivided": true,
"stockStatusChangedAuto": 0,
"extensionAttributes":

,
"options": [],
"tierPrices": [],
"customAttributes": []
,
"saveOptions": true
';

$options = array(
CURLOPT_VERBOSE=>0,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_USERAGENT=>"Mozilla/4.0 (compatible;)",
CURLOPT_POST=>true,
CURLOPT_POSTFIELDS=>$post
);

curl_setopt_array($ch, $options);
$result = curl_exec($ch);
$result= json_decode($result);
print_r($result);
return $result;


after run this I recieved the following message:



stdClass Object ( [message] => Server cannot understand Content-Type HTTP header media type application/x-www-form-urlencoded )


honestly I have many days trying to resolve this issue but not luck until now. So that is why I am asking for help now.



So thank you in advance for any help.










share|improve this question
















bumped to the homepage by Community 12 mins ago


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















  • check this magento.stackexchange.com/q/132149/20064

    – Piyush
    Jan 31 '18 at 16:42













1












1








1








I´m a newbie with Magento 2 and the REST API so I need a little help with this code because I tried many things and the result is always the same.



$adminUrl='http://mylink.com/index.php/rest/V1/integration/admin/token';
$ch = curl_init();
$data = array("username" => "user", "password" => "password");
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
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);
$token= json_decode($token);

$headers = array("Authorization: Bearer $token");

$requestUrl='http://mylink.com/magento2/index.php/rest/V1/products';

$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);

$post ='
"product":
"sku": "0010001234",
"name": "PRODUCTO DE PRUEBA",
"attributeSetId": "4",
"price": 20,
"status": 1,
"visibility": 4,
"typeId": "virtual",
"weight": 0,
"extensionAttributes":
"stockItem":

"stockId": 1,
"qty": 20,
"isInStock": true,
"isQtyDecimal": false,
"useConfigMinQty": true,
"minQty": 0,
"useConfigMinSaleQty": 0,
"minSaleQty": 0,
"useConfigMaxSaleQty": true,
"maxSaleQty": 0,
"useConfigBackorders": false,
"backorders": 0,
"useConfigNotifyStockQty": true,
"notifyStockQty": 20,
"useConfigQtyIncrements": false,
"qtyIncrements": 0,
"useConfigEnableQtyInc": false,
"enableQtyIncrements": false,
"useConfigManageStock": true,
"manageStock": true,
"lowStockDate": "string",
"isDecimalDivided": true,
"stockStatusChangedAuto": 0,
"extensionAttributes":

,
"options": [],
"tierPrices": [],
"customAttributes": []
,
"saveOptions": true
';

$options = array(
CURLOPT_VERBOSE=>0,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_USERAGENT=>"Mozilla/4.0 (compatible;)",
CURLOPT_POST=>true,
CURLOPT_POSTFIELDS=>$post
);

curl_setopt_array($ch, $options);
$result = curl_exec($ch);
$result= json_decode($result);
print_r($result);
return $result;


after run this I recieved the following message:



stdClass Object ( [message] => Server cannot understand Content-Type HTTP header media type application/x-www-form-urlencoded )


honestly I have many days trying to resolve this issue but not luck until now. So that is why I am asking for help now.



So thank you in advance for any help.










share|improve this question
















I´m a newbie with Magento 2 and the REST API so I need a little help with this code because I tried many things and the result is always the same.



$adminUrl='http://mylink.com/index.php/rest/V1/integration/admin/token';
$ch = curl_init();
$data = array("username" => "user", "password" => "password");
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
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);
$token= json_decode($token);

$headers = array("Authorization: Bearer $token");

$requestUrl='http://mylink.com/magento2/index.php/rest/V1/products';

$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);

$post ='
"product":
"sku": "0010001234",
"name": "PRODUCTO DE PRUEBA",
"attributeSetId": "4",
"price": 20,
"status": 1,
"visibility": 4,
"typeId": "virtual",
"weight": 0,
"extensionAttributes":
"stockItem":

"stockId": 1,
"qty": 20,
"isInStock": true,
"isQtyDecimal": false,
"useConfigMinQty": true,
"minQty": 0,
"useConfigMinSaleQty": 0,
"minSaleQty": 0,
"useConfigMaxSaleQty": true,
"maxSaleQty": 0,
"useConfigBackorders": false,
"backorders": 0,
"useConfigNotifyStockQty": true,
"notifyStockQty": 20,
"useConfigQtyIncrements": false,
"qtyIncrements": 0,
"useConfigEnableQtyInc": false,
"enableQtyIncrements": false,
"useConfigManageStock": true,
"manageStock": true,
"lowStockDate": "string",
"isDecimalDivided": true,
"stockStatusChangedAuto": 0,
"extensionAttributes":

,
"options": [],
"tierPrices": [],
"customAttributes": []
,
"saveOptions": true
';

$options = array(
CURLOPT_VERBOSE=>0,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_USERAGENT=>"Mozilla/4.0 (compatible;)",
CURLOPT_POST=>true,
CURLOPT_POSTFIELDS=>$post
);

curl_setopt_array($ch, $options);
$result = curl_exec($ch);
$result= json_decode($result);
print_r($result);
return $result;


after run this I recieved the following message:



stdClass Object ( [message] => Server cannot understand Content-Type HTTP header media type application/x-www-form-urlencoded )


honestly I have many days trying to resolve this issue but not luck until now. So that is why I am asking for help now.



So thank you in advance for any help.







magento-2.1 rest rest-api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 1 '18 at 17:24







Dan Y. Goldfeder

















asked Jan 30 '18 at 23:09









Dan Y. GoldfederDan Y. Goldfeder

62




62





bumped to the homepage by Community 12 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 12 mins ago


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














  • check this magento.stackexchange.com/q/132149/20064

    – Piyush
    Jan 31 '18 at 16:42

















  • check this magento.stackexchange.com/q/132149/20064

    – Piyush
    Jan 31 '18 at 16:42
















check this magento.stackexchange.com/q/132149/20064

– Piyush
Jan 31 '18 at 16:42





check this magento.stackexchange.com/q/132149/20064

– Piyush
Jan 31 '18 at 16:42










1 Answer
1






active

oldest

votes


















0














Well, after I found the application POSTMAN I could fix my problem and now the code is working. Here is how it must to be.



<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "http://mylink.com/index.php/rest/V1/products",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "nt"product": ntttt"sku": "0010001234",ntttt"name": "producto de prueba",ntttt"attributeSetId": "4",n "price": 20,n "status": 1,n "visibility": 4,n "typeId": "virtual",n "weight": 0,n "extensionAttributes": n "stockItem": n n "stockId": 1,n "qty": 20,n "isInStock": true,n "isQtyDecimal": false,n "useConfigMinQty": true,n "minQty": 0,n "useConfigMinSaleQty": 0,n "minSaleQty": 0,n "useConfigMaxSaleQty": true,n "maxSaleQty": 0,n "useConfigBackorders": false,n "backorders": 0,n "useConfigNotifyStockQty": true,n "notifyStockQty": 20,n "useConfigQtyIncrements": false,n "qtyIncrements": 0,n "useConfigEnableQtyInc": false,n "enableQtyIncrements": false,n "useConfigManageStock": true,n "manageStock": true,n "lowStockDate": "string",n "isDecimalDivided": true,n "stockStatusChangedAuto": 0,n "extensionAttributes": n n ,n "options": [],n "tierPrices": [],n "customAttributes": []n ,n "saveOptions": truennnt",
CURLOPT_HTTPHEADER => array(
"Cache-Control: no-cache",
"Content-Type: application/json",
"Postman-Token: token",
"User-Agent: Mozilla/4.0 (compatible)"
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err)
echo "cURL Error #:" . $err;
else
echo $response;






share|improve this answer























    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%2f211590%2fmagento-2-really-need-help-server-can%25c2%25b4t-understand-content-type-http-header%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














    Well, after I found the application POSTMAN I could fix my problem and now the code is working. Here is how it must to be.



    <?php

    $curl = curl_init();

    curl_setopt_array($curl, array(
    CURLOPT_URL => "http://mylink.com/index.php/rest/V1/products",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "nt"product": ntttt"sku": "0010001234",ntttt"name": "producto de prueba",ntttt"attributeSetId": "4",n "price": 20,n "status": 1,n "visibility": 4,n "typeId": "virtual",n "weight": 0,n "extensionAttributes": n "stockItem": n n "stockId": 1,n "qty": 20,n "isInStock": true,n "isQtyDecimal": false,n "useConfigMinQty": true,n "minQty": 0,n "useConfigMinSaleQty": 0,n "minSaleQty": 0,n "useConfigMaxSaleQty": true,n "maxSaleQty": 0,n "useConfigBackorders": false,n "backorders": 0,n "useConfigNotifyStockQty": true,n "notifyStockQty": 20,n "useConfigQtyIncrements": false,n "qtyIncrements": 0,n "useConfigEnableQtyInc": false,n "enableQtyIncrements": false,n "useConfigManageStock": true,n "manageStock": true,n "lowStockDate": "string",n "isDecimalDivided": true,n "stockStatusChangedAuto": 0,n "extensionAttributes": n n ,n "options": [],n "tierPrices": [],n "customAttributes": []n ,n "saveOptions": truennnt",
    CURLOPT_HTTPHEADER => array(
    "Cache-Control: no-cache",
    "Content-Type: application/json",
    "Postman-Token: token",
    "User-Agent: Mozilla/4.0 (compatible)"
    ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err)
    echo "cURL Error #:" . $err;
    else
    echo $response;






    share|improve this answer



























      0














      Well, after I found the application POSTMAN I could fix my problem and now the code is working. Here is how it must to be.



      <?php

      $curl = curl_init();

      curl_setopt_array($curl, array(
      CURLOPT_URL => "http://mylink.com/index.php/rest/V1/products",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "nt"product": ntttt"sku": "0010001234",ntttt"name": "producto de prueba",ntttt"attributeSetId": "4",n "price": 20,n "status": 1,n "visibility": 4,n "typeId": "virtual",n "weight": 0,n "extensionAttributes": n "stockItem": n n "stockId": 1,n "qty": 20,n "isInStock": true,n "isQtyDecimal": false,n "useConfigMinQty": true,n "minQty": 0,n "useConfigMinSaleQty": 0,n "minSaleQty": 0,n "useConfigMaxSaleQty": true,n "maxSaleQty": 0,n "useConfigBackorders": false,n "backorders": 0,n "useConfigNotifyStockQty": true,n "notifyStockQty": 20,n "useConfigQtyIncrements": false,n "qtyIncrements": 0,n "useConfigEnableQtyInc": false,n "enableQtyIncrements": false,n "useConfigManageStock": true,n "manageStock": true,n "lowStockDate": "string",n "isDecimalDivided": true,n "stockStatusChangedAuto": 0,n "extensionAttributes": n n ,n "options": [],n "tierPrices": [],n "customAttributes": []n ,n "saveOptions": truennnt",
      CURLOPT_HTTPHEADER => array(
      "Cache-Control: no-cache",
      "Content-Type: application/json",
      "Postman-Token: token",
      "User-Agent: Mozilla/4.0 (compatible)"
      ),
      ));

      $response = curl_exec($curl);
      $err = curl_error($curl);

      curl_close($curl);

      if ($err)
      echo "cURL Error #:" . $err;
      else
      echo $response;






      share|improve this answer

























        0












        0








        0







        Well, after I found the application POSTMAN I could fix my problem and now the code is working. Here is how it must to be.



        <?php

        $curl = curl_init();

        curl_setopt_array($curl, array(
        CURLOPT_URL => "http://mylink.com/index.php/rest/V1/products",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => "nt"product": ntttt"sku": "0010001234",ntttt"name": "producto de prueba",ntttt"attributeSetId": "4",n "price": 20,n "status": 1,n "visibility": 4,n "typeId": "virtual",n "weight": 0,n "extensionAttributes": n "stockItem": n n "stockId": 1,n "qty": 20,n "isInStock": true,n "isQtyDecimal": false,n "useConfigMinQty": true,n "minQty": 0,n "useConfigMinSaleQty": 0,n "minSaleQty": 0,n "useConfigMaxSaleQty": true,n "maxSaleQty": 0,n "useConfigBackorders": false,n "backorders": 0,n "useConfigNotifyStockQty": true,n "notifyStockQty": 20,n "useConfigQtyIncrements": false,n "qtyIncrements": 0,n "useConfigEnableQtyInc": false,n "enableQtyIncrements": false,n "useConfigManageStock": true,n "manageStock": true,n "lowStockDate": "string",n "isDecimalDivided": true,n "stockStatusChangedAuto": 0,n "extensionAttributes": n n ,n "options": [],n "tierPrices": [],n "customAttributes": []n ,n "saveOptions": truennnt",
        CURLOPT_HTTPHEADER => array(
        "Cache-Control: no-cache",
        "Content-Type: application/json",
        "Postman-Token: token",
        "User-Agent: Mozilla/4.0 (compatible)"
        ),
        ));

        $response = curl_exec($curl);
        $err = curl_error($curl);

        curl_close($curl);

        if ($err)
        echo "cURL Error #:" . $err;
        else
        echo $response;






        share|improve this answer













        Well, after I found the application POSTMAN I could fix my problem and now the code is working. Here is how it must to be.



        <?php

        $curl = curl_init();

        curl_setopt_array($curl, array(
        CURLOPT_URL => "http://mylink.com/index.php/rest/V1/products",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => "nt"product": ntttt"sku": "0010001234",ntttt"name": "producto de prueba",ntttt"attributeSetId": "4",n "price": 20,n "status": 1,n "visibility": 4,n "typeId": "virtual",n "weight": 0,n "extensionAttributes": n "stockItem": n n "stockId": 1,n "qty": 20,n "isInStock": true,n "isQtyDecimal": false,n "useConfigMinQty": true,n "minQty": 0,n "useConfigMinSaleQty": 0,n "minSaleQty": 0,n "useConfigMaxSaleQty": true,n "maxSaleQty": 0,n "useConfigBackorders": false,n "backorders": 0,n "useConfigNotifyStockQty": true,n "notifyStockQty": 20,n "useConfigQtyIncrements": false,n "qtyIncrements": 0,n "useConfigEnableQtyInc": false,n "enableQtyIncrements": false,n "useConfigManageStock": true,n "manageStock": true,n "lowStockDate": "string",n "isDecimalDivided": true,n "stockStatusChangedAuto": 0,n "extensionAttributes": n n ,n "options": [],n "tierPrices": [],n "customAttributes": []n ,n "saveOptions": truennnt",
        CURLOPT_HTTPHEADER => array(
        "Cache-Control: no-cache",
        "Content-Type: application/json",
        "Postman-Token: token",
        "User-Agent: Mozilla/4.0 (compatible)"
        ),
        ));

        $response = curl_exec($curl);
        $err = curl_error($curl);

        curl_close($curl);

        if ($err)
        echo "cURL Error #:" . $err;
        else
        echo $response;







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 1 '18 at 17:27









        Dan Y. GoldfederDan Y. Goldfeder

        62




        62



























            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%2f211590%2fmagento-2-really-need-help-server-can%25c2%25b4t-understand-content-type-http-header%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

            Best approach to update all entries in a list that is paginated?Best way to add items to a paginated listChoose Your Country: Best Usability approachUpdate list when a user is viewing the list without annoying themWhen would the best day to update your webpage be?What should happen when I add a Row to a paginated, sorted listShould I adopt infinite scrolling or classical pagination?How to show user that page objects automatically updateWhat is the best location to locate the comments section in a list pageBest way to combine filtering and selecting items in a listWhen one of two inputs must be updated to satisfy a consistency criteria, which should you update (if at all)?

            Вунгтау (аеропорт) Загальні відомості | Див. також | Посилання | Навігаційне меню10°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.0833310°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.083337731608Vinh AirportVinh airport facelift improves serviceвиправивши або дописавши їївиправивши або дописавши їїр

            Тонконіг бульбистий Зміст Опис | Поширення | Екологія | Господарське значення | Примітки | Див. також | Література | Джерела | Посилання | Навігаційне меню1114601320038-241116202404kew-435458Poa bulbosaЭлектронный каталог сосудистых растений Азиатской России [Електронний каталог судинних рослин Азіатської Росії]Малышев Л. Л. Дикие родичи культурных растений. Poa bulbosa L. - Мятлик луковичный. [Малишев Л. Л. Дикі родичи культурних рослин. Poa bulbosa L. - Тонконіг бульбистий.]Мятлик (POA) Сем. Злаки (Мятликовые) [Тонконіг (POA) Род. Злаки (Тонконогові)]Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Description from Flora of China) [Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Опис від Флора Китаю)]Poa bulbosa L. – lipnice cibulkatá / lipnica cibulkatáPoa bulbosa в базі даних Poa bulbosa на сайті Poa bulbosa в базі даних «Global Biodiversity Information Facility» (GBIF)Poa bulbosa в базі даних «Euro + Med PlantBase» — інформаційному ресурсі для Євро-середземноморського розмаїття рослинPoa bulbosa L. на сайті «Плантариум»