Using Yellow Pages.com using providers like FSharp

I registered for the yellow pages.com API program found here: https://publisher.yp.com/home .

I went to call and I return to JSON in the browser: http://pubapi.atti.com/search-api/search/devapi/search?term=Jumbo+China+5&searchloc=6108+Falls+Of+Neuse+ Rd + 27609 & format = json & key = ZZZZZZZZ

When I take json results and put it in Json2CSharp, it displays fine. When I try to upload it to a provider like:

typeListListJson = JsonProvider <@ " http://pubapi.atti.com/search-api/search/devapi/search?term=Jumbo+China+5&searchloc=6108+Falls+Of+Neuse+Rd+27609&format=json&key=ZZZZZZZ " >

I get 400

Looking at the violinist, I see "User Agent - Required Field"

Has anyone come across this before? How to add user agent to type provider?

Thanks in advance

+3
source share
2 answers

The latest version of F # Data now always sends a user agent and accepts headers, so now this should work directly:

type RestaurantListingJson = JsonProvider<"http://pubapi.atti.com/search-api/search/devapi/search?term=Jumbo+China+5&searchloc=6108+Falls+Of+Neuse+Rd+27609&format=json&key=ZZZZZZZ">
+1
source

I did not create an account, so I could not try this, but if the error message says "user agent is a required field", then I assume that the service requires setting the User-AgentHTTP request header .

JsonProvider, - JSON, ( yp.json), :

type Yp = JsonProvider<"yp.json">

( ), Http.RequestString, headers - , User-Agent:

let response = 
  Http.RequestString("http://httpbin.org/user-agent", headers=["user-agent", "test"])

Yp.Parse(response) ( Load URL-, ).

+4

All Articles