6
votes

I want to use odata type provider but it causes next error while compiling: (407) proxy authentication required. There are no errors at design time. Does anybody know how to set the proxy in type provider? Sample code:

open Microsoft.FSharp.Data.TypeProviders
type db = ODataService<"http://ebayodata.cloudapp.net/">
[<EntryPoint>]
     let main argv=
           let eBay = db.GetDataContext()
           0
2
Maybe this post provides some clues: markhneedham.com/blog/2009/07/11/… - Christian
What happens if you specify credentials? Ebay.Credentials <- System.Net.NetworkCredential("user", "pass", "domain") - Robert Jeppesen
Sorry, that was stupid, you said it was during compile-time, not run-time. - Robert Jeppesen

2 Answers

2
votes

This blog posting mentions some sample code which may cover proxies.

The Freebase type provider can be used with .NET 3.5, .NET 4.0, .NET 4.5, Silverlight and Portable programming. A proxy may be needed in some cases. The projects in Tests\ProjectsUsingTypeProvider.sln show some sample libraries for these different cases.

You might wish to look at this file specifically as well.

0
votes

Try to specify a default web proxy as follows:

open System.Net // for WebProxy etc.
open Microsoft.FSharp.Data.TypeProviders

// put here actual proxy address
let proxy = new WebProxy("http://192.168.1.1:3128") :> IWebProxy
// put here your credentials if needed
proxy.Credentials <- NetworkCredential("proxy_user", "password")
// set up a default proxy
WebRequest.DefaultWebProxy <- proxy

// here the default proxy will be used
type db = ODataService<"http://ebayodata.cloudapp.net/">

Or you can try to use a proxy which was specified in IE as follows:

WebRequest.DefaultWebProxy <- WebRequest.GetSystemWebProxy()
WebRequest.DefaultWebProxy.Credentials <- CredentialCache.DefaultNetworkCredentials

If you have an error while compiling then this is probably because of F# compiler (Fsc.exe) can't connect to the proxy server. You can fix this by modifying Fsc.exe.config, just add the following text under the configuration section:

  <system.net>
    <defaultProxy useDefaultCredentials="true" />    
  </system.net>