Histórico da Página
Cloak | ||
---|---|---|
| ||
#include "protheus.ch" //------------------------------------------------------------------- /*/{Protheus.doc} x16165 Função para post na API /api/batch/contratos em https://seusite.com.br, utilizando da classe @sample U_x16165() @author Daniel Mendes @since 22/03/2019 @version 1.0 /*/ //------------------------------------------------------------------- user function x16165() local oRestClient as object local cUrl as char local cPath as char local aHeadOut as array local oFile as object cUrl := "https://seusite.com.br" cPath := "/api/batch/contratos" aHeadOut := {} Aadd(aHeadOut, "Authorization: Basic " + Encode64("app01:fTdUlDgdQQ4MRQhLahykiKhON6k97Zfly5SV6fwpa5zCE")) Aadd(aHeadOut, "Content-Type: application/json") Aadd(aHeadOut, "Content-Encoding: gzip") oFile := FwFileReader():New("\contratos_20190316.gz") if oFile:Open() oRestClient := FWRest():New(cUrl) oRestClient:SetPath(cPath) oRestClient:SetPostParams(Encode64(oFile:FullRead())) oFile:Close() if oRestClient:Post(aHeadOut) showResult(oRestClient:GetResult()) else showResult(oRestClient:GetLastError()) endif FWFreeVar(@oRestClient) endif FWFreeVar(@oFile) return nil //------------------------------------------------------------------- /*/{Protheus.doc} showResult Exibe o resultado do método POST, sendo em console ou tela @param cValue String contendo o conteúdo que será exibido @sample showResult("Teste") @author Daniel Mendes @since 22/03/2019 @version 1.0 /*/ //------------------------------------------------------------------- static function showResult(cValue) if IsBlind() Conout(cValue) else MsgInfo(cValue) endif return nil |
Exemplo
...
Toggle Cloak | ||
---|---|---|
|
...
...
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas