Amiguinhos,
Vou deixar umas dicas aqui quem sabe clareia a cabecinha:
Function EnviarJSONporWebService()
local oWS, sDataRaw, sAuthorization
oWS := TOleAuto():New( "MSXML2.ServerXMLHTTP.6.0" )
if ValType(oWS) <> "O"
return nil
endif
sDataRaw := '{' + CRLF + ;
'"items": [' + CRLF + ;
' {' + CRLF + ;
' "name": "Meu Produto",' + CRLF + ;
' "value": 7500,' + CRLF + ;
' "amount": 1' + CRLF + ;
' }' + CRLF + ;
'],' + CRLF + ;
'"customer": {' + CRLF + ;
' "name": "Gorbadoc Oldbuck",' + CRLF + ;
' "cpf": "94271564656",' + CRLF + ;
' "phone_number": "5144916523"' + CRLF + ;
'},' + CRLF + ;
'"expire_at": "2018-12-20",' + CRLF + ;
'"configurations": {' + CRLF + ;
' "fine": 200,' + CRLF + ;
' "interest": 33' + CRLF + ;
' },' + CRLF + ;
'"message": "Este é um espaço de até 80 caracteres para informar algo a seu cliente",' + CRLF + ;
'"repeats": 5,' + CRLF + ;
'"split_items": false' + CRLF + ;
'}'
// Certificado que vamos usar do armazem de certificados de Windows.
oWS:SetOption( 3, "Nome do certificado" )
oWS:Open( "POST", "https://sandbox.gerencianet.com.br/v1/carnet", .f. )
// Caso seja necessario definir timeouts
// Os valores sao em milisegundos
oWS:setTimeouts( 15000, 15000, 600000, 600000 )
// Metodo chamados
oWS:SetRequestHeader( "Content-Type", "application/json" )
oWS:SetRequestHeader( "Authorization", sAuthorization )
// Enviamos a informacao JSON
oWS:send( sDataRaw )
MsgInfo( "Resposta: " + oWS:responsexml:xml)
return ""
function EnviarJSONporDOS()
local sDataRaw, sAuthorization, sParameters
sDataRaw := '{' + CRLF + ;
'"items": [' + CRLF + ;
' {' + CRLF + ;
' "name": "Meu Produto",' + CRLF + ;
' "value": 7500,' + CRLF + ;
' "amount": 1' + CRLF + ;
' }' + CRLF + ;
'],' + CRLF + ;
'"customer": {' + CRLF + ;
' "name": "Gorbadoc Oldbuck",' + CRLF + ;
' "cpf": "94271564656",' + CRLF + ;
' "phone_number": "5144916523"' + CRLF + ;
'},' + CRLF + ;
'"expire_at": "2018-12-20",' + CRLF + ;
'"configurations": {' + CRLF + ;
' "fine": 200,' + CRLF + ;
' "interest": 33' + CRLF + ;
' },' + CRLF + ;
'"message": "Este é um espaço de até 80 caracteres para informar algo a seu cliente",' + CRLF + ;
'"repeats": 5,' + CRLF + ;
'"split_items": false' + CRLF + ;
'}'
sParameters := [ --location --request POST 'https://sandbox.gerencianet.com.br/v1/carnet' ] + ;
[ --header 'Authorization: {{Authorization}}' ] + ;
[ --header 'Content-Type: application/json' ] + ;
[ --data-raw ] + sDataRaw + ;
[ > GNCURL.TXT]
cMacro := "GNCURL.BAT"
cComando := "CURL.EXE " + sParameters
errhandle := fCreate( cMacro )
fWrite( errhandle, cComando )
fClose( errhandle )
//
// MsgRun( "Aguarde o termino do processo", "Envio de Email...", {|| WaitRun( cMacro, 0 ) } )
Run( cMacro, 0 )
//
cRetorno := MemoRead( "GNCURL.TXT" )
return nil