PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 25 → Transformando um retorno httprequest pegando o content encode base 64 e convertendo para buffer de um pdf e salvando em disco e visualizando o resultado
Transformando um retorno httprequest pegando o content encode base 64 e convertendo para buffer de um pdf e salvando em disco e visualizando o resultado
Iniciado por Boller, 28,feb. 2025 14:24 - No hay respuesta
Miembro registrado
3.855 mensajes
Publicado el 28,febrero 2025 - 14:24
//Exemplo Transformando um retorno httprequest pegando o content encode base 64 e convertendo para buffer de um pdf e salvando em disco e visualizando o resultado

minharequisicao is string
hReq is httpRequest
hReq.Content =[
{"empresa": "%1", "usuario": "%2", "senha": "%3", "codigodebarras": "%4"}
]
minharequisicao = StringBuild(hReq.Content,cEmpresa,cUsuario,csenha,TABLE_Historico_boleto.COL_Codigodebarras)
hReq.Content = minharequisicao
hReq.Method = httpPost
hReq.URL = "http://acesso.ctrcsistema.com.br:7077/GESTORATRANSP/rest/consultaboleto/baixarpdf"
hReq.ContentType = "application/json"

//envio
hRes is httpResponse = HTTPSend(hReq)

resp_json is JSON = hRes.Content //retorno

bufpdf is Buffer = Decode(resp_json.pdf,encodeBASE64)

ok is boolean

IF fSaveBuffer(fCurrentDir()+fSep()+"boleto.pdf",bufpdf) = True THEN
ok = True
OpenMobileWindow(WIN_PDFReader,fCurrentDir()+fSep()+"boleto.pdf")
ELSE
ok = False
Info("Não foi possivel gerar o boleto")
END

SIPVisible(False)

MyWindow..Plane = 3 //achei o erro fsep no windows \ e fsep no linux /

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/