Search code examples
androidapipush-notificationwebclientpushbullet

Pushbullet + WebClient = download only body content from note notification


This is my first attempt to use the Pushbullet API to read the latest notification sent.

I have successfully authenticated my WebClient and upload/download its last push, but I want to download only the body (note's message) from the push of note type. If you guys take a look at the example bellow, the WebClient.DownloadString brings not only the body, but also every information available from the push.

Is there a way to download only the note's message, and not everything from it?

wc.DownloadString("https://api.pushbullet.com/v2/pushes?limit=1");

Result:

"{\"accounts\":[],\"blocks\":[],\"channels\":[],\"chats\":[],\"clients\":[],\"contacts\":[],\"devices\":[],\"grants\":[],\"pushes\":[{\"active\":true,\"iden\":\"ujCch9rXhnwsjAvxQ1EFi0\",\"created\":1.454030974949465e+09,\"modified\":1.454031099564189e+09,\"type\":\"note\",\"dismissed\":true,\"direction\":\"self\",\"sender_iden\":\"ujCch9rXhnw\",\"sender_email\":\"[email protected]\",\"sender_email_normalized\":\"[email protected]\",\"sender_name\":\"ABC\",\"receiver_iden\":\"ujCch9rXhnw\",\"receiver_email\":\"[email protected]\",\"receiver_email_normalized\":\"[email protected]\",\"title\":\"abc\",\"body\":\"test line 1\r\ntest line 2\r\ntest line 3\"}],\"profiles\":[],\"subscriptions\":[],\"texts\":[],\"cursor\":\"eyJWZXJzaW9uIjoxLCJNb2RpZmllZEFmdGVyIjoiMDAwMS0wMS0wMVQwMDowMDowMFoiLCJNb2RpZmllZEJlZm9yZSI6IjIwMTYtMDEtMjlUMDE6MzE6MzkuNTY0MTg5WiJ9\"}"


Solution

  • In the API, no. The easiest way is to parse the response with a JSON parser and get response["pushes"][0]["body"]