• 0
NatanMall

"description":[{"plain_text":""} help

Question

alguém pode me ajudar com isso??

    "description":[
        {"plain_text":"Detalhes do Produto"}
    ],

a formula JSON esta correta, mais o retorno da API é!

{
    "message": "body.invalid_field_types",
    "error": "validation_error",
    "status": 400,
    "cause": [
        {
            "cause_id": 101,
            "type": "error",
            "code": "body.invalid_field_types",
            "references": [
                "item.description"
            ],
            "message": "invalid property type: [description] expected String but was JSONArray value: [[plain_text:]]"
        }
    ]
}

e quando eu mando sem o plain_text  API retorna um warning: The text property is deprecated. And will soon be rejected. Please use plain_text

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

$objAnuncio = new StdClass();

$objAnuncio->description = ['plain_text'=>'Descrição aqui'];

 

Não esqueça os headers corretos:

$headers = [
            'Accept'=>'application/json',
            'Content-Type'=>'application/json',
        ];

 

Avisa ai se deu certo. 🙂

Share this post


Link to post
Share on other sites
  • 0

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.mercadolibre.com/items?access_token=APP_USR-1076320792228583-121310-79a14b9d74f74790f715584fcb28ce6c-385942583",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{"title":"Batedeira Cadence 8 Velocidades 400W - 220v - não Ofertar",
"category_id":"MLB196958",
"price":910,
"currency_id":"BRL",
"available_quantity":2,
"buying_mode":"buy_it_now",
"listing_type_id":"bronze",
"condition":"new",
"description":[{"plain_text":"Detalhes do Produto<br>Batedeira Orbit Colors da Cadence"}],
"video_id": "",
"warranty": "12 meses",
"pictures":[{"source":"https://teste.achaddo.com.br/panel/data/Ray_Ban_Original_Wayfarer.jpg"},
{"source":"https://teste.achaddo.com.br/panel/data/Teashades.gif"}
]}",
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
"Content-Type: application/json",
"Postman-Token: 0174cbf3-c5c4-4f95-9f08-4c7071028c10",
"cache-control: no-cache"),
));

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

curl_close($curl);

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

----------------------------------------------------------------------------------------------------

o retorno no postman é esse

{
    "message": "body.invalid_field_types",
    "error": "validation_error",
    "status": 400,
    "cause": [
        {
            "cause_id": 101,
            "type": "error",
            "code": "body.invalid_field_types",
            "references": [
                "item.description"
            ],
            "message": "invalid property type: [description] expected String but was JSONArray value: [[plain_text:Detalhes do Produto<br>Batedeira Orbit Colors da Cadence.]]"
        }
    ]
}

a formula JSON esta correta, não sei o que esta acontecendo!

Edited by NatanMall

Share this post


Link to post
Share on other sites
  • 1
43 minutes ago, NatanMall said:

"description":[{"plain_text":"Detalhes do Produto<br>Batedeira Orbit Colors da Cadence"}],

mude para:

"description":{"plain_text":"Detalhes do Produto<br>Batedeira Orbit Colors da Cadence"}

 

OBS.: retire a tag <br> , como o próprio nome diz é plain_text (texto plano), não devem ser utilizadas tags HTML

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...