开发者

Create a DataContext and provide an API Key

开发者 https://www.devze.com 2023-01-27 03:54 出处:网络
i need some help with the following: i have a wcf data service with some api authorization mechanism. that works, if i enter the service url in the browser. it validates the api key and gives me data

i need some help with the following:

i have a wcf data service with some api authorization mechanism. that works, if i enter the service url in the browser. it validates the api key and gives me data.

in another project, i added the service url as a service reference and like to instanciate a EntityFramework DataContext object, but what i wanted was, that the given URI to the constructor of that DataContext needs to have an api-key in there.

if i try to pass that api key as a query-parameter, i get an error: "Expected an absolute, well formed http URL without a query or fragment."

ok t开发者_JAVA百科hat message points out clearly what i did wrong, but how can i get the apiKey included?

greets, chris


I've found the answer on social.msdn.com. Basically, you need to use the AddQueryOption method of a resource proxy, like:

SomeService.SomeResource.AddQueryOption("apikey", "1234")

0

精彩评论

暂无评论...
验证码 换一张
取 消