Domanda

I would like to send push notifications via prowl. But i can't get it work. I don't know exactly how to put multiple arguments into the Body. Here is the Prowl API Description

My Code

inets:start().
ssl:start().

Url = "https://prowl.weks.net/publicapi/add".
Head = "".
ContentType = "application/x-www-form-urlencoded".
Body = "apikey=longeapikey application=Erlang description=something.

httpc:request(post, {Url, Head, ContentType, Body}, [], []).

Error I get

<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<prowl>\n<error code=\"400\">Missing field: Application is required.</error>\n</prowl>\n"

Thank you for your help

È stato utile?

Soluzione

I think the body has to be URL encoded. You'll need to separate your parameters with ampersands.

Body = "apikey=longeapikey&application=Erlang&description=something".

There are Erlang libraries which help simplify REST calls: https://github.com/kivra/restclient for example.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top