4 MINDS

4MINDS Gestão de Conhecimento

Firebase send data example


EX 1 ------------
def firebaseUrl = "https://4gym.firebaseio.com/.json";
 
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 firebaseUrl = "https://4gym.firebaseio.com/.json";
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;