Jump to content
Fivewin Brasil

API BLING


infosys2

Recommended Posts

Estou tentando fazer um post  na  API BLING    e  gostaria da  ajuda dos colegas.

Fazendo experiências primeiro com CURL.EXE  mandando um post  de cadastro na api conforme segue:.

 

E estou recebendo este retorno de erro no xml:  

{"retorno":{"erros":[[{"erro":{"cod":6,"msg":"Start tag expected, '<' not found\n"}}]]}}

Alguem poderia dar uma forca para mim.   NO final de tudo quero montar uma funcao em arbur para fazer esta interacao.

 

 curl -X POST "https://bling.com.br/Api/v2/deposito/json/"
      -d "apikey=81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13"
      -d "xml=dep001.xml"
 

<?xml version="1.0" encoding="UTF-8"?>
<depositos>
    <deposito>
        <descricao>Depósito Padrão</descricao
        <situacao>A</situacao>
        <depositoPadrao>true</depositoPadrao>
        <desconsiderarSaldo>false</desconsiderarSaldo>
    </deposito>
</depositos>

 

Link to comment
Share on other sites

NDIR VISUALIZAÇÃO
 
Com este codigo dar a menssagem que nao foi informato a chave key .... mas nao tenho a meno ideia de como passar esta chave key se alguem poder ajudar ficarei imenssamente grato.
 

//------------------------------------------------------------------------------------------------
function Send( )
   
   hCurl := curl_easy_init()
   
   cUrl := "https://bling.com.br/Api/v2/produtos/json/"
   cKey := "?apikey=81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13"
   //cKey := "apikey=81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13"
   cKey := "81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13"
   cXml:= "<produto><codigo></codigo><descricao>Caneta Preta 001 xxxx</descricao><situacao>Ativo</situacao><descricaoCurta>Descrição curta da caneta</descricaoCurta><descricaoComplementar>Descrição produto 002</descricaoComplementar><un>Pc</un><vlr_unit>1.68</vlr_unit><preco_custo>1.23</preco_custo><peso_bruto>0.2</peso_bruto><peso_liq>0.18</peso_liq><class_fiscal>1000.01.01</class_fiscal><marca>Marca da Caneta</marca><origem>0</origem><estoque>10</estoque><deposito><id>14886559917</id><estoque>200</estoque></deposito><gtin>223435780</gtin><gtinEmbalagem>54546</gtinEmbalagem><largura>11</largura><altura>21</altura><profundidade>31</profundidade><estoqueMinimo>1.00</estoqueMinimo><estoqueMaximo>100.00</estoqueMaximo><cest>28.040.00</cest><idGrupoProduto>12345</idGrupoProduto><condicao>Novo</condicao><freteGratis>N</freteGratis><linkExterno>https://minhaloja.com.br/meu-produto</linkExterno><observacoes>Observações do meu produtos</observacoes><producao>P</producao><dataValidade>20/11/2019</dataValidade><descricaoFornecedor>Descrição do fornecedor</descricaoFornecedor><idFabricante>0</idFabricante><codigoFabricante>123</codigoFabricante><unidadeMedida>Centímetros</unidadeMedida><garantia>4</garantia><itensPorCaixa>2</itensPorCaixa><volumes>2</volumes><urlVideo>https://www.youtube.com/watch?v=zKKL-SgC5lY</urlVideo><imagens><url>https://bling.com.br/bling.jpg</url></imagens><idCategoria>4573031</idCategoria></produto>"
 *  Local httpcode

   curl_easy_setopt( hCurl, HB_CURLOPT_POST, 1 )
   curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrl + cKey )
  * curl_easy_setopt( hCurl, HB_CURLOPT_USERPWD, "xxxxxxxxxx$#B<SHJGHKxxxx" + ':' + "x@#$F&^%DEE" )
   
   /* define nome de usuário e senha para autenticação */
    *curl_easy_setopt(hCurl, 26 , cKey )
    *curl_easy_setopt( hCurl, 5, cKey )
    *curl_easy_setopt(hCurl, 87, cKey)
    //CURLOPT_HTTPHEADER 23
    curl_easy_setopt(hCurl, 23, "apikey: 81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13");
   curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
   curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
*    curl_easy_setopt(hCurl, 131, cXml )
    curl_easy_setopt (hCurl, 36 , "PUT" )
    curl_easy_setopt(hCurl, 15, cXml)
   //  aqui vai o xml do PUT DELETE OU POST
  // curl_easy_setopt( hcurl, HB_CURLOPT_POSTFIELDS, Send() )  15
   nError := curl_easy_perform( hCurl )
   ? nError
*   curl_easy_getinfo( hCurl, HB_CURLINFO_RESPONSE_CODE, @httpcode )

      cResponse := curl_easy_dl_buff_get( hCurl )

  ?  cResponse
 
return NIL            
Link to comment
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
Reply to this topic...

×   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...
×
×
  • Create New...