Android Question cURL to implement Firebase Realtimedatabase transaction

Alex Guerrero

Member
Licensed User
Hello, I am trying to update data with conditional requests in Firebase Realtimedatabase, but I do not get the unique identifier or ETag, please can you help me, thanks.

The idea is to implement a secure transaction in Firebase Realtimedatabase.

The example base code is in the following link
https://firebase.google.com/docs/database/rest/save-data#section-conditional-requests

The curl code is the following:
curl 'https://apptugaraje-6d8a3.firebaseio.com/serdata/201805/03005656790lXtl7/esta.json' -H 'X-Firebase-ETag: true'

B4X:
Dim job1 As HttpJob
job1.Initialize("FiBaDb_read", Me)
job1.Download( "https://apptugaraje-6d8a3.firebaseio.com/serdata/201805/03005656790lXtl7/esta.json" )
job1.GetRequest.SetHeader("X-Firebase-ETag","true")

What am I doing wrong?

The answer should be something similar to the image.

response_curl.png
 

Alex Guerrero

Member
Licensed User
Hello @Erel, the output is correct, after reading in the forum, i realized that you can not get the header with the library OkHttpUtils2,
to solve my question remove the OkHttpUtils2 library and add HttpUtils2 version 2.62 (based on OkHttp library), as you recommended in the following link.

https://www.b4x.com/android/forum/threads/httputils2-getheaders.45051/

The source code HttpUtils2
https://www.b4x.com/android/forum/threads/b4x-okhttputils2-ihttputils2-httputils2-source-code.82632/

My suggestion to not have to remove the library and use the source code is that please add an option to get the header and so also avoid the message :HttpUtils2Service is declared twice.

Thank you very much.
 
Upvote 0
Top