RestSharp.dll というライブラリーを使います。
RestSharp.dll へのシンボリックリンクを コンパイル、実行するフォルダー内に作成します。
http_post.fs
// ----------------------------------------------------------------
//
// http_post.fs
//
// Mar/08/2018
//
// ----------------------------------------------------------------
open System
open RestSharp
// ----------------------------------------------------------------
[<EntryPoint>]
let main argv =
Console.Error.WriteLine("*** 開始 ***")
let host_in = "https://httpbin.org"
let user = "jiro"
let password = "123456"
printfn "host_in = %s" host_in
//
let client = new RestClient(host_in)
let request = new RestRequest("/post", Method.POST)
let _ = request.AddParameter("user", user)
let _ = request.AddParameter("password", password)
//
let response = client.Execute(request)
let content = response.Content
printfn "%s" content
Console.Error.WriteLine("*** 終了 ***")
0
// ----------------------------------------------------------------
Makefile
http_post.exe : http_post.fs
fsharpc http_post.fs -r:RestSharp.dll
clean:
rm -f *.exe
コンパイル
$ make
fsharpc http_post.fs -r:RestSharp.dll
F# Compiler for F# 4.0 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License
実行コマンド
mono ./http_post.exe