• 0
Sign in to follow this  
Bernardweger

Problema ao inserir variação (custom)

Question

url = 'https://api.mercadolibre.com/items/'.$idprodmercado[$i].'/variations?access_token='.$token.'';
				$params = [array(
					"price" => "250",
					"available_quantity" => "3",
					"picture_ids" => array(
						"teste"
					),
					"attribute_combinations" => array(
						array(
							"name" => "Tamanho",
							"value_name" => "G"
						)
			

					)

				)];

//url-ify the data for the POST
$paramss = http_build_query($params);

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $paramss);

//execute post
$result = curl_exec($ch);
echo $result; 

Olá pessoal, boa tarde, estou precisando de um help, estou desenvolvendo um sistema que atualiza as variações de acordo com o meu produto cadastrado no sistema já com suas variações, até ai tudo bem...

 

Más na hora de inserir a variação no produto ele me retorno este erro:

{"message":"body.invalid","error":"A body is expected. (B)","status":400,"cause":[]}1

 

Segue código, estou fazendo com curl... ALGUEM ME AJUDA PORFAVOR, Obrigado:

 

url = 'https://api.mercadolibre.com/items/'.$idprodmercado[$i].'/variations?access_token='.$token.'';

$params = [array(
"price" => "250",
"available_quantity" => "3",
"picture_ids" => array(
"teste"
),
"attribute_combinations" => array(
array(
"name" => "Tamanho",
"value_name" => "G"
)
 
 
)
 
)];
 
//url-ify the data for the POST
$paramss = http_build_query($params);
 
//open connection
$ch = curl_init();
 
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $paramss);
 
//execute post
$result = curl_exec($ch);
echo $result;

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

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