• 0
Sign in to follow this  
aotech

Error al actualizar stock item

Question

Hola cuando quiero actualizar el stock de la variante de un item me genera un error (API .NET):

 

Item:

 

{
    "id": "MLA599310665",
    "site_id": "MLA",
    "variations": [{
        "id": 10459731042,
        "attribute_combinations": [{
            "id": "83000",
            "name": "Color Primario",
            "value_id": "92001",
            "value_name": "AMARILLO"
        }, {
            "id": "73002",
            "name": "Talle",
            "value_id": "131994",
            "value_name": "16"
        }],
        "price": 1,
        "available_quantity": 2,
        "sold_quantity": 0,
        "picture_ids": ["294311-MLA20541577539_012016"],
        "seller_custom_field": null
    }]
}
 

Obtengo el item publicado:

 

var oJsonResult = meli.Get("/items/MLA599310665", listParam);

 

Modifico la cantidad de la variante para el item:

 

foreach (var vari in oJsonResult.variations)
                {
                    vari.available_quantity = "2";
                }

 

Actualizo item:

 

meli.Put("/items/MLA599310665", listParam, oJsonResult);

 

Error:

{"message":"Cannot update item MLA599310665 [status:active, has_bids:false]","error":"validation_error","status":400,"cause":[{"code":"item.listing_type_id.not_modifiable","message":"listing_type_id is not modifiable."},{"code":"item.site_id.not_modifiable","message":"site_id is not modifiable."},{"code":"item.category_id.not_modifiable","message":"category_id is not modifiable."},{"code":"item.available_quantity.not_modifiable","message":"available_quantity is not modifiable."},{"code":"item.price.not_modifiable","message":"price is not modifiable."},{"code":"item.description.not_modifiable","message":"description is not modifiable."}]}

 

 

Segundo Intento

 

Obtengo el item publicado:

 

var oJsonResult = meli.Get("/items/MLA599310665", listParam);

 

Actualizo item:

 

meli.Put("/items/MLA599310665", listParam, new MercadoLibre.variations { id = "10459731042" ,available_quantity = "2"});

 

Error:

 

{"message":"Cannot update item MLA599310665 [status:active, has_bids:false]","error":"validation_error","status":400,"cause":[{"code":"item.id.not_modifiable","message":"id is not modifiable."},{"code":"item.available_quantity.not_modifiable","message":"available_quantity is not modifiable."}]}

 

 

Gracias.

 

Saludos.

 

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Item que tem variações você deve fazer a alteração na quantidade da variação, não na quantidade disponível do anúncio.

 

 

La cantidad la estoy modificando en la variación no en el articulo, te dejo la estructura del json:

 

Item:

 

{
    "id": "MLA599310665",
    "site_id": "MLA",

    "currency_id": "ARS",

  1. "initial_quantity": 2,
  2. "available_quantity": 2,
  3. "sold_quantity": 0,
  4. "buying_mode": "buy_it_now",
  5. "listing_type_id": "bronze",
    "variations": [{
        "id": 10459731042,
        "attribute_combinations": [{
            "id": "83000",
            "name": "Color Primario",
            "value_id": "92001",
            "value_name": "AMARILLO"
        }, {
            "id": "73002",
            "name": "Talle",
            "value_id": "131994",
            "value_name": "16"
        }],
        "price": 1,
        "available_quantity": 2,
        "sold_quantity": 0,
        "picture_ids": ["294311-MLA20541577539_012016"],
        "seller_custom_field": null
    }]
}

Share this post


Link to post
Share on other sites
  • 0

não mexa nos seus itens 1 e 2.

Apenas na variação 10459731042 em  available_quantity   = (int)5;

 

public class variations
        {
            public int available_quantity { get; set; }
        }

 

meli.Put("/items/MLA599310665", listParam, new MercadoLibre.variations { id = "10459731042" ,available_quantity = 2});

 

{"message":"Cannot update item MLA599310665 [status:active, has_bids:false]","error":"validation_error","status":400,"cause":[{"code":"item.id.not_modifiable","message":"id is not modifiable."},{"code":"item.available_quantity.not_modifiable","message":"available_quantity is not modifiable."}]}
 
 
meli.Put("/items/MLA599310665", listParam, new MercadoLibre.variations {available_quantity = 2});
 
{"message":"Cannot update item MLA599310665 [status:active, has_bids:false]","error":"validation_error","status":400,"cause":[{"code":"item.available_quantity.not_modifiable","message":"available_quantity is not modifiable."}]}

Share this post


Link to post
Share on other sites
  • 0

Fiz um teste e uso PHP, mas o conceito é o mesmo

 

$altera = $meli->put("/items/$LISTING_ID/variations/$VARIATION_ID"
          array(
               "available_quantity"=> $QTY
          ),
          array("access_token"=>, ........)
);
 
Penso que para você deve ficar assim:
meli.Put("/items/MLA599310665/variations/10459731042", listParam, new MercadoLibre.variations {available_quantity = 2});

Share this post


Link to post
Share on other sites
  • 0

Hola aotech,

Como resolviste esto? tengo el mismo inconveniente. no se si enviar en el put solo el string json con la variante a la cual modifique el stock, si envío todo el articulo, o solo las variantes incluyendo la que modifique. Ojala lo hayas podido resolver, saludos.

Share this post


Link to post
Share on other sites
  • 0

A mi me ha servidor de la siguiente manera:
Tengo un item MLA599310665 y ese item tiene 5 variaciones. Si envío solo la variación a modificar eliminar las 5 variaciones y solo me deja la variación que modifique (realmente no se porque lo hace). Por lo que si necesito modificar una variación, envío mis 5 variaciones nuevamentes (variations) con el precio e inventario / stock que deseo y listo. Quedaría algo así:

meli.PUT('/items/MLA599310665', $access_token, array( array('id' => '10459731042' , 'available_quantity' => 2), array('id' => '10459731043' , 'available_quantity' => 3), array('id' => '10459731044' , 'available_quantity' => 4), array('id' => '10459731045' , 'available_quantity' => 5) ) );

Espero te sirva, Saludos!

Share this post


Link to post
Share on other sites
  • 0
On 8/5/2018 at 1:14 PM, MatiasCloudERP said:

Hola aotech,

Como resolviste esto? tengo el mismo inconveniente. no se si enviar en el put solo el string json con la variante a la cual modifique el stock, si envío todo el articulo, o solo las variantes incluyendo la que modifique. Ojala lo hayas podido resolver, saludos.

Hola, yo lo resolvi asi ... si tenes variaciones le pasas : Put("/items/" + item + "/variations/" + variacion , parametros, new variations { id= variacion , available_quantity = 1 });

donde item y variacion son variables con valores .

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this