Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
NickJosevski
/
jira-cookie-auth-comment-post.fs
Last active
Apr 8, 2016
Star
0
Fork
0
Star
Code
Revisions
3
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
Cookie based authentication with JIRA (F# and RestSharp)
Raw
jira-cookie-auth-comment-post.fs
open
RestSharp
type
PostData
=
{
body
:
string
}
type
Login
=
{
username
:
string
password
:
string
}
let
uname
=
"
admin
"
let
pw
=
"
your-password
"
let
restClient
=
RestSharp.RestClient
(
"
https://your-account.atlassian.net
"
)
let
authReq
=
RestSharp
.RestRequest
(
"
/rest/auth/1/session
"
)
.AddJsonBody
({
username
=
uname
;
password
=
pw
})
let
authResponse
=
restClient.Post authReq
printfn
"
response StatusCode:
%A
"
authResponse.StatusCode
let
cookiesToAdd
=
authResponse.Cookies
|>
Seq.map
(
fun
x
->
(
x.Name
,
x.Value
))
let
addCommentReq
=
RestSharp
.RestRequest
(
"
/rest/api/2/issue/Issue-Id/comment
"
)
.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
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.