Skip to content

Instantly share code, notes, and snippets.

@kurt-mueller-osumc
Created September 28, 2020 20:15
Show Gist options
  • Save kurt-mueller-osumc/d6ae5092f4aa0e7f590fea699e2535b2 to your computer and use it in GitHub Desktop.
Save kurt-mueller-osumc/d6ae5092f4aa0e7f590fea699e2535b2 to your computer and use it in GitHub Desktop.
Creating JSON bodies, using anonymous F# records, for API requests
type Request = {
ApiToken: ApiToken
ProjectId: ProjectId
StartingAt: ObjectId option
}
module Request =
let toJson request =
let (ProjectId projectId) = request.ProjectId
let baseJson = {| scope = {| project = projectId
recurse = true |}
describe = true |}
match request.StartingAt with
| Some (ObjectId objectId) ->
{| baseJson with starting = {| project = projectId
id = objectId |} |}
| None ->
baseJson
@kurt-mueller-osumc
Copy link
Author

The F# compiler gives me the following errors for line 20:

This anonymous record does not have enough fields. Add the missing fields [starting].F# Compiler(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment