firebase post data

Firebase send data example

Identificador: 11789
Autor: Alan Rodrigues   segunda-feira, Dia 1 de maio de 2023, às 03:00:08 horas
Revisado Por:    quarta-feira, Dia 6 de junho de 2018, às 15:16:10 horas
Visualização: Todos

Pontos: 0   Acessos: 4108

EX 1 ------------
 
dataToSubmit = ' { "target" : "BACKUP_FILE" , ' +
           '   "tenantId" : "38", ' +
           '   "description" : "backup", ' +
           '   "operation" : "BACKUP_FILE", ' +
           '   "resource" : "BACKUP_FILE"}'
 
def connection = firebaseUrl.toURL().openConnection()
connection.setDoOutput(true)
connection.setRequestMethod("POST");

connection.outputStream.withWriter {
    Writer writer -> writer << dataToSubmit;
};

def response = connection.inputStream.withReader { Reader reader -> reader.text }
return response;

EX 2 ------------
def inst = new Date().format('dd/MM/yyyy HH:mm:ss')
println inst
dataToSubmit = ' { "target" : "ACESSO_REMOTO" , ' +
           '   "tenantId" : "16", ' +
           '   "instant" : "'+inst+'", ' +
           '   "id" : "126497", ' +
           '   "description" : "Alan Rodrigues", ' +
           '   "operation" : "ACESSO_REMOTO", ' +
           '   "resource" : "ACESSO_REMOTO"}'
 
def connection = firebaseUrl.toURL().openConnection()
connection.setDoOutput(true)
connection.setRequestMethod("POST");

connection.outputStream.withWriter {
    Writer writer -> writer << dataToSubmit;
};

def response = connection.inputStream.withReader { Reader reader -> reader.text }
return response;

Postar um comentário