简体   繁体   中英

httpc Erlang Body

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM