Android Question [Solved] Send Json to Google Service

Descartex

Well-Known Member
Licensed User
Longtime User
Hi.
I'm trying to send a json file to a google service.
I've readed the API Doc, and at the example, it uses curl to send all the params to the Google Service.
I need to know how i can send the json file i implement with the config needed to make the service work.

B4X:
curl -v -k -s -H "Content-Type: application/json" \
    https://service.googleapis.com/v1/service:annotate?key=<API-key> \
    --data-binary @/Users/<username>/testdata/mycreation.json

I have already the API-Key, and checked it works (At the Google example page).
mycreation.json is checked that has the format google service needs.

Thanks in advance.

[Edited]
Data must be sent by POST.
 

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hello,
I have took a look at curl's options used and think that the POST request could be done using OKHttpUtils2 on address https://service.googleapis.com/v1/service:annotate?key=<API-key> and specifying the header "Content-Type: application/json"

Here are its command options :

-v, --verbose Make the operation more talkative
-k, --insecure Allow connections to SSL sites without certs (H)
-s, --silent Silent mode. Don't output anything
-H, --header LINE Custom header to pass to server (H)
--data-binary DATA HTTP POST binary data (H)
 
Upvote 0

Descartex

Well-Known Member
Licensed User
Longtime User
Hi, lemonisdead.
Thanks for your fast answer.
But... how can i send the json file with OKHttpUtils2??

Thanks.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
See my Dropbox Class.
It is using Headers and sending json to Dropbox.

I´m sure you´ll find what you need in the Class-Code.

It is all using okhttputils2
 
Upvote 0

Descartex

Well-Known Member
Licensed User
Longtime User
Thanks to both...
I have to read slowly your class, DonManfred, it seems to be interesting for my intentions.
Lemonisdead, PostFile... I didn't know this method... looking at docs, it seems to be easier.

I must make the test this afternoon... After that, I'll tell you the results.

Thank you again.
 
Upvote 0

Descartex

Well-Known Member
Licensed User
Longtime User
Hi.
It worked with PostBytes.
File is sent successfully.
Now I have to fight against the configuration :-(
Thanks a lot.
 
Upvote 0
Top