Hi Luri,
There may be a better way but you could construct the Basic Auth header by
hand and set in the outgoing $req_headers.
Something similar in here:
https://openacs.org/api-doc/proc-view?proc=util::http::basic_auth&source_p=1

On Sun, 21 Feb 2021 at 23:34, Iuri de Araujo Sampaio <i...@iurix.com> wrote:

> Hello there,
> I’m trying to rewrite a CURL request to Naviserver.
>
> curl '
> https://api.twilio.com/2010-04-01/Accounts/ACe13c882f57e87c4b4db37/Messages.json
> ' -X POST \ --data-urlencode 'To=whatsapp:+5511998865465' \
> --data-urlencode 'From=whatsapp:+14155238886' \ --data-urlencode 'Body=Your
> Yummy Cupcakes Company order of 1 dozen frosted cupcakes has shipped and
> should be delivered on July 10, 2019. Details:
> http://www.yummycupcakes.com/' \ -u [Authkey]:[AuthToken]
>
>
> man url
>  -u, --user <user:password>
>               Specify the user name and password to use for server
> authentication. Overrides -n, --netrc and --netrc-optional.
>
>               If you simply specify the user name, curl will prompt for a
> password.
> …
>
>
>
> So basically, data-urlencode becomes posta_data. How could -u argument can
> be rewritten to [ns_http run …] arguments
>
>
> set post_data [list]
> lappend "[ns_urlencode to]=[ns_urlencode whatsapp:+5511998865465]"
> lappend "[ns_urlencode From]=[ns_urlencode whatsapp:+14155238886]"
> lappend "[ns_urlencode Body]=[ns_urlencode \"Your Yummy Cupcakes Company
> order of 1 dozen frosted cupcakes has shipped and should be deli\
> vered\"]"
>
> set url "
> https://api.twilio.com/2010-04-01/Accounts/ACe13c431f82f57e87c4b4db37/Messages.json
> "
>
> set res [ns_http run -method POST -headers $req_headers -body $post_data $
> url]
> ns_log Notice "RES2 $res"
>
>
>
> I was looking for references in the documentation, however I haven’t found
> any matches. What's the replacement of curl -u in ns_http?
>
> References:
> https://naviserver.sourceforge.io/n/naviserver/files/ns_http.html
>
>
> Best wishes,
> I
> _______________________________________________
> naviserver-devel mailing list
> naviserver-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/naviserver-devel
>


-- 

*David Osborne | Software Engineer*
Qcode Software, Castle House, Fairways Business Park, Inverness, IV2 6AA
*Email:* da...@qcode.co.uk | *Phone:* 01463 896 484
www.qcode.co.uk
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to