Prowl API TCPClient Request [resolved]

Hi there, I’m interested in sending an API request to Prowl, an iPhone notification service. I’m having difficulty understanding what my header file that I’d send via tcp client would look like, I understand how to make the request but adding parameters is where I’m stuck, could anyone help please?

Hi @rickpbush,

I’m guessing the Prowl API request is a HTTP request. There’s a great thread happening here with an HTTP Client library for just those sorts of requests!

Thanks,
David

1 Like

Ah brilliant, thank you so much :slight_smile:

Ok, anyone else wanting to do this it really is as simple as I thought it should be :

for the spark core do this :
TCPClient client; if (client.connect("api.prowlapp.com", 80))     {         Serial.println(F("Command connected"));         client.write("POST https://api.prowlapp.com/publicapi/add?apikey=SECRET_KEY_HERE& application=SOMETHING%20HERE&event=EVENT%20NAME&description=THE%20EVENT%20DESCRIPTION%20HERE&priority=1&url=http://www.google.com HTTP/1.1\r\nHost: api.prowlapp.com:8080\r\nContent Type: application/x-www-form-urlencoded\r\n\r\n");         client.stop();     }
and for the arduino do the same but use a tcp client object of your choice.

3 Likes

It’s interesting that they allow you to POST to /add and allow you to pass all the variables via the URL querystring. Usually all those need to go down in the body of the request instead of the URL. Glad it works that way since it makes it a little easier!

2 Likes

First off, I just want to say thanks for this rickpbush. Just an FYI. I ran into an issue with this after Prowl did some sever maintenance on 2016 03 13. I modified the code slightly and it is again working. See below.

client.connect("api.prowlapp.com", 80)
CharsWrote = client.println(“GET /publicapi/add? apikey=SecretKey&application=AppName&event=EVENTID%20Message&description=DESCRIPTION&priority=PRORITYLEVEL&url=REFSITE HTTP/1.1\r\nHost: api.prowlapp.com:80\r\n”)

this also works

client.connect("api.prowlapp.com", 80)
CharsWrote = client.println(“POST /publicapi/add? apikey=SecretKey&application=AppName&event=EVENTID%20Message&description=DESCRIPTION&priority=PRORITYLEVEL&url=REFSITE HTTP/1.1\r\nHost: api.prowlapp.com:80\r\n”)

@cdrodriguez
I tried to use your example in a modified WebClient example. Filled in all parameters like apikey, application, event and so on. I get connected to api.prowlapp.com but no further reaction. Adding a notification on the Prowl Site works perfect. Could i ask you to help me and send me a small example which i could use with my apices.

i added a var like this: int CharsWrote = client.println("POST https://api.prowlapp.com/publicapi/add?apikey=
and it returns a number with chars written. So i thought it should work. But no sign of work.

Are you using a photon or the older spark core? I have found that the old firmware of the spark core does not support this method. If you are using a photon what is the value returned from client.println, i.e., “CharsWrote”.