• 0
Sign in to follow this  
mendoca

Invalid invoices type

Question

Bom dia estou tentando enviar um xml de uma nfe para o mercado livre

utilizando a função:

$param = array(
      'data' => $data['pathnfe']
);
    
$url = parent::$API_DOMAIN.'/shipments/'.$data['shipment_id'].'/invoices?access_token='.$this->accessToken;
$nfe = $this->callAPI($url,'PUT', json_encode($param));   

mas o que me retorna é o seguinte erro:

object(stdClass)#58 (4) { ["message"]=> string(21) "Invalid invoices type" ["error"]=> string(21) "invalid_invoices_type" ["status"]=> int(400) ["cause"]=> object(stdClass)#1524 (8) { ["cause"]=> NULL ["error"]=> string(21) "invalid_invoices_type" ["internal_cause"]=> array(0) { } ["localized_message"]=> string(21) "Invalid invoices type" ["message"]=> string(21) "Invalid invoices type" ["stack_trace"]=> array(12) { [0]=> object(stdClass)#70 (5) { ["className"]=> string(37) "com.mercadolibre.fbm.utils.CheckUtils" ["fileName"]=> string(17) "CheckUtils.groovy" ["lineNumber"]=> int(44) ["methodName"]=> string(14) "checkParameter" ["nativeMethod"]=> bool(false) } [1]=> object(stdClass)#1397 (5) { ["className"]=> string(36) "com.mercadolibre.fbm.utils.BodyUtils" ["fileName"]=> string(16) "BodyUtils.groovy" ["lineNumber"]=> int(26) ["methodName"]=> string(8) "readBody" ["nativeMethod"]=> bool(false) } [2]=> object(stdClass)#1396 (5) { ["className"]=> string(36) "com.mercadolibre.fbm.utils.BodyUtils" ["fileName"]=> string(16) "BodyUtils.groovy" ["lineNumber"]=> int(19) ["methodName"]=> string(8) "readBody" ["nativeMethod"]=> bool(false) } [3]=> object(stdClass)#1409 (5) { ["className"]=> string(55) "com.mercadolibre.fbm.invoices.ShipmentInvoiceController" ["fileName"]=> string(32) "ShipmentInvoiceController.groovy" ["lineNumber"]=> int(34) ["methodName"]=> string(11) "putInvoices" ["nativeMethod"]=> bool(false) } [4]=> object(stdClass)#1408 (5) { ["className"]=> string(56) "grails.plugin.cache.web.filter.PageFragmentCachingFilter" ["fileName"]=> string(30) "PageFragmentCachingFilter.java" ["lineNumber"]=> int(198) ["methodName"]=> string(8) "doFilter" ["nativeMethod"]=> bool(false) } [5]=> object(stdClass)#1410 (5) { ["className"]=> string(45) "grails.plugin.cache.web.filter.AbstractFilter" ["fileName"]=> string(19) "AbstractFilter.java" ["lineNumber"]=> int(63) ["methodName"]=> string(8) "doFilter" ["nativeMethod"]=> bool(false) } [6]=> object(stdClass)#1411 (5) { ["className"]=> string(50) "com.ml.public2private.filters.Public2PrivateFilter" ["fileName"]=> string(25) "Public2PrivateFilter.java" ["lineNumber"]=> int(65) ["methodName"]=> string(8) "doFilter" ["nativeMethod"]=> bool(false) } [7]=> object(stdClass)#1412 (5) { ["className"]=> string(29) "com.jsonp.filters.JsonpFilter" ["fileName"]=> string(16) "JsonpFilter.java" ["lineNumber"]=> int(58) ["methodName"]=> string(8) "doFilter" ["nativeMethod"]=> bool(false) } [8]=> object(stdClass)#1413 (5) { ["className"]=> string(29) "com.brandseye.cors.CorsFilter" ["fileName"]=> string(15) "CorsFilter.java" ["lineNumber"]=> int(82) ["methodName"]=> string(8) "doFilter" ["nativeMethod"]=> bool(false) } [9]=> object(stdClass)#1415 (5) { ["className"]=> string(39) "java.util.concurrent.ThreadPoolExecutor" ["fileName"]=> string(23) "ThreadPoolExecutor.java" ["lineNumber"]=> int(1142) ["methodName"]=> string(9) "runWorker" ["nativeMethod"]=> bool(false) } [10]=> object(stdClass)#1414 (5) { ["className"]=> string(46) "java.util.concurrent.ThreadPoolExecutor$Worker" ["fileName"]=> string(23) "ThreadPoolExecutor.java" ["lineNumber"]=> int(617) ["methodName"]=> string(3) "run" ["nativeMethod"]=> bool(false) } [11]=> object(stdClass)#1416 (5) { ["className"]=> string(16) "java.lang.Thread" ["fileName"]=> string(11) "Thread.java" ["lineNumber"]=> int(748) ["methodName"]=> string(3) "run" ["nativeMethod"]=> bool(false) } } ["status"]=> int(400) ["suppressed"]=> array(0) { } } }

 

lembrando que estou enviando o conteúdo da nfe e não o arquivo em si, seguindo os passos dessa explicação que encontrei na documentação no seguinte link:https://developers.mercadolibre.com/pt_br/fulfillment-como-gerar-nota-fiscal-de-venda#Enviar-nota-fiscal-eletrônica

Enviar nota fiscal eletrônica

Com todas informações disponíveis, você deverá gerar a NFe (Nota Fiscal eletrônica). Depois de gerada, você deverá enviá-las para o Mercado Livre realizando um PUT conforme o exemplo a seguir:

curl -X PUT -H "Content-Type: application/json" -H "Accept: application/json" -d

'[{"data":"(inserte aquí el XML de la NFE)"}]'

https://api.mercadolibre.com/shipments/{shipment_id}/invoices?access_token=YOUR_ACCESS_TOKEN

No caso que o PUT seja correto você obterá 201 OK. Possiveis erros: XML sin cuerpo Result: {"message":"No invoices present","error":"no_invoices_present","status":400,"cause":null} XML mal formado Result: {"message":"Malformed XML","error":"malformed_xml","status":400,"cause":null} Con errores en los campos del XML: Result: {"message":"Invalid Invoice File","error":"invalid_invoice","status":400,"cause":null}

 

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

Guest
This topic is now closed to further replies.
Sign in to follow this