Last active
          August 3, 2020 16:37 
        
      - 
      
- 
        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
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /// 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