开发者

OData and ApiKey url-parameter through ServiceReference

开发者 https://www.devze.com 2023-02-27 10:45 出处:网络
ApiKey is used to control the usage and it is affixed as an url parameter (开发者_运维百科implemented using somewhat modified version of this solution). Question is, how to go about appending this par

ApiKey is used to control the usage and it is affixed as an url parameter (开发者_运维百科implemented using somewhat modified version of this solution). Question is, how to go about appending this parameter when consuming the API through the use of the ServiceReference in Visual Studio?


It seems to work just fine if you use the full URL to the $metadata in the Add Service Reference dialog in VS. So for example http://services.odata.org/OData/OData.svc/$metadata?apiKey=1234 works, and it does send the query string as specified.


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

精彩评论

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