Search code examples
f#type-providersf#-data

F# Type providers and Sky Biometry


Has anyone used the F# type providers with Sky Biometry?

A majority of the calls work great with the type providers. However, when I call the faces/recognize method, I am getting fails using both the Json and the Xml type provider.

Using the Json one, I declare the type like this:

type skybiometryJsonFaceRecognition = JsonProvider<"http://api.skybiometry.com/fc/faces/recognize.json?uids=default@ImageComparer&urls=https://lg2014dev.blob.core.windows.net/d69bdda9-d934-448c-acae-99019f3a564f/01ee184f-ff0b-426f-872a-cbc81ef58d90.jpg&api_key=XXXXX&api_secret=yyyyy">

When I try and use the type in my code, it is failing on the last part of the graph:

let recognition = skybiometryJsonFaceRecognition.Load(stringBuilder.ToString())

It should be:

recognition.Photos.[0].Tags.[0].Uids.[0].confidence

But instead I get:

recognition.Photos.[0].Tags.[0].Uids.[0].JsonValue

I then swapped over to the Xml type provider for just this one call and I am getting intellisense working:

let recognition = skybiometryXmlFaceRecognition.Load(stringBuilder.ToString())
recognition.Photos.Photo.Tags.Tag.Uids.Uid.Confidence

But when I run it, I get

System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

Looking at the XML in a call from my browser, it sure looks fine to me:

enter image description here

Does anyone have any suggestions? Thanks


Solution

  • Thanks to ntr's suggestion, I changed the type def to use local storage. The Json TP then found all of the props and the actual call worked as expected. Thanks everyone.