Daniel, boa tarde!
Segue o fonte que estou desenvolvendo, espero que ajude
// BIBLIOTECAS NECESSÁRIAS
INCLUDE "TOTVS.CH"
INCLUDE "RESTFUL.CH"
include 'protheus.ch'
include 'parmtype.ch'
User Function S_PRODUTO()
local aHeader := {}
local oRest
Local cError := ""
local cRetornoSite := ""
local cBody := ''
local cURL := ''
local cPath := ''
cURL += "https://schomolz.plima.me"
cPath += "/api/produtos"
//Instacia da classe
oRest:=FWRest():New(cURL)
//-- Endpoint
oRest:SetPath(cPath)
//-- Cabeçalho de requisição
AAdd(aHeader, "Content-Type: application/json" )
cBody := '{'
cBody += ' "codigo_prod": "33433",'
cBody += ' "formato": "Retangular",'
cBody += ' "descricao": "33433 RETALHO",'
cBody += ' "aisi": "M2",'
cBody += ' "tipo": "ACO FERRAMENTA",'
cBody += ' "altura": 56,'
cBody += ' "largura": 78,'
cBody += ' "comprimento": 143,'
cBody += ' "quantidade_kg": 6.4,'
cBody += ' "valor_item": 82.45'
cBody += '}'
oRest:SetPostParams("body")
oRest:SetPostParams(cBody)
if oRest:Post(aHeader)
cError := ""
nStatus := HTTPGetStatus(@cError)
if nStatus >= 200 .And. nStatus <= 299
if Empty(oRest:getResult())
MsgInfo(nStatus)
else
cError := oRest:GetLastError()
cRetornoSite:= oRest:GetResult()
showResult(cError + CRLF + cRetornoSite )
endif
else
MsgStop(cError)
endif
else
cError := oRest:GetLastError()
cRetornoSite:= oRest:GetResult()
showResult(cError)
endif
return
static function showResult(cValue)
if IsBlind()
Conout(cValue)
else
MsgInfo(cValue)
endif
return nil
Eduardo, nunca vi essa situação, como você está utilizando a classe FWRest? Você tem um exemplo para reproduzir isso?
— Daniel Mendes 12 de Nov de 2020