Skip to content

Instantly share code, notes, and snippets.

@kurt-mueller-osumc
Last active August 3, 2020 16:37
Show Gist options
  • Save kurt-mueller-osumc/5d9f2b84cae803882014fd26ace2410e to your computer and use it in GitHub Desktop.
Save kurt-mueller-osumc/5d9f2b84cae803882014fd26ace2410e to your computer and use it in GitHub Desktop.
A simple example of F# code that calls the DNAnexus API
/// Code for accessing the DNAnexus api
/// https://documentation.dnanexus.com/developer/api/
namespace DX.Api
open FSharp.Data
open FSharp.Data.HttpRequestHeaders
open Newtonsoft.Json
/// DNAnexus Search API
/// https://documentation.dnanexus.com/developer/api/search
module Search =
/// Search for data objects
/// https://documentation.dnanexus.com/developer/api/search#api-method-system-finddataobjects
module DataObjects =
/// Make an http request to search data objects by project given a valid api token.
let request apiToken (projectId:string) =
let body = {| scope = {| project = projectId
recurse = true |}
describe = true |}
Http.Request
( "https://api.dnanexus.com/system/findDataObjects",
httpMethod = "POST",
silentHttpErrors = true,
headers = [ ContentType HttpContentTypes.Json
"Authorization", ("Bearer " + apiToken) ],
body = TextRequest (JsonConvert.SerializeObject(body)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment