Pessoal, boa tarde.
Estou com um erro ao consumir uma api rest, onde preciso enviar no body as informações com urlencoded. Inclusive segui esse post como referencia enter link description here mas não obtive sucesso. Abaixo segue o código de exemplo:
User Function TSINTSF01()
Local oRest := Nil
Local lOk := .T.
Local aHeadOut := {}
Local cUrl := ""
Local cUrlPrd := "https://login.salesforce.com/services/oauth2/token"
Local cClIDSL := SuperGetMv("FS_CLIDSL",.f.,"3MVG9Kip4IKAZQEX1t_G4QZp6.SSZIS0DS.d8g5ldZuNKZPlzcx73TWE8NCLvTwYbF4hWdvz8VffQ7nrdqUDu") // CLIENT ID SALES FORCE
Local cClSCSL := SuperGetMv("FS_CLSCSL",.f.,"378369B75426D2C56CF4C9D18F7C20408EE27504A99AB9A215E49385F457A8A3") // CLIENT SECRES SALES FORCE
Local cUNamSL := SuperGetMv("FS_USNMSL",.f.,"integration@morigd.com.br") // USER NAME SALES FORCE
Local cPassSL := SuperGetMv("FS_PASWSL",.f.,"Nvn*495*@&Z00iTvB*X&VtSjZIECGAycBq6Nr2AS6DXgqJ4a!Swfd425%IlmpmTpq5hfQrX2TsquxSnW2VDRp") // PASSWORD SALES FORCE
aadd(aHeadOut,'Content-Type: application/x-www-form-urlencoded')
//cUrl += cHttpSL+'?'
cUrl += 'grant_type='+escape('password')+'&'
cUrl += 'client_id='+escape(cClIDSL)+'&'
cUrl += 'client_secret='+escape(cClSCSL)+'&'
cUrl += 'username='+escape(cUNamSL)+'&'
cUrl += 'password='+escape(cPassSL)+''
//Testa a produção
oRest := FWRest():New(cUrlPrd)
oRest:setPath('')
oRest:SetPostParams(cUrl)
lOk := oRest:Post(aHeadOut)
If lOk
MsgInfo("Conexão sales force concluida na test")
Else
MsgStop("Erro de conexão - "+ oRest:GetLastError())
EndIf
Return Nil
Tentei utilizar o HttpPost, porém obtive o mesmo erro: 400 BadRequest
Alguém tem alguma dica? Obrigado