Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Cookie based authentication with JIRA (F# and RestSharp)
open RestSharp
type PostData = {
body: string
type Login = {
username : string
password : string
let uname = "admin"
let pw = "your-password"
let restClient = RestSharp.RestClient("")
let authReq =
.AddJsonBody({ username = uname; password = pw })
let authResponse = restClient.Post authReq
printfn "response StatusCode: %A" authResponse.StatusCode
let cookiesToAdd =
|> (fun x -> (x.Name, x.Value))
let addCommentReq =
.AddJsonBody({ body = "a new comment" })
for (name, value) in cookiesToAdd do
printfn "cookie name: %s value: %s" name value
addCommentReq.AddCookie(name, value) |> ignore
let commentResp = restClient.Post addCommentReq
printfn "add comment StatusCode: %A" commentResp.StatusCode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment