Skip to main content

F Sharp

GET

module httpRequestTest
open System.Net.Http
open System.IO
open System.Text

task {
use client = new HttpClient()
client.DefaultRequestHeaders.Accept.Clear()
client.DefaultRequestHeaders.Add("apiKey", "< YOURTOKEN >")
use bodyContent = new StringContent("{\"options\": { \"method\": \"GET\",\"headers\": {\"Content-Type\": \"application/json\",\"Accept\": \"application/json\"}}, \"url\": \"/rest/api/3/issue/DEV-16\"}", System.Text.Encoding.UTF8, "application/json")

let! response =
let url = new System.Uri("<YOUR ENDPOINT URL>")
client.PostAsync(url, bodyContent)

let! jiraResponse = response.Content.ReadAsStringAsync()
printfn $"jira response: {jiraResponse}"
}

|> Async.AwaitTask
|> Async.RunSynchronously

POST

module httpRequestTest
open System.Net.Http
open System.IO
open System.Text

task {
use client = new HttpClient()
client.DefaultRequestHeaders.Accept.Clear()
client.DefaultRequestHeaders.Add("apiKey", "< YOURTOKEN >")
use bodyContent = new StringContent("{
\"options\": {
\"method\": \"POST\",
\"headers\": {
\"Content-Type\": \"application/json\",
\"Accept\": \"application/json\"
},
\"body\": {
\"fields\": {
\"project\":{
\"name\": \"<your project name>\"
},
\"summary\": \"Create Issue via POST.\",
\"description\": \"Creating of an issue via a POST request using the API Key Manager\",
\"issuetype\": {
\"id\": \"<your issue type id>\"
}
}
}
},
\"url\": \"/rest/api/2/issue\"
}", System.Text.Encoding.UTF8, "application/json")

let! response =
let url = new System.Uri("<YOUR ENDPOINT URL>")
client.PostAsync(url, bodyContent)

let! jiraResponse = response.Content.ReadAsStringAsync()
printfn $"jira response: {jiraResponse}"
}

|> Async.AwaitTask
|> Async.RunSynchronously