开发者

LinqPad, odata and apikey url-parameter

开发者 https://www.devze.com 2023-01-19 19:42 出处:网络
I run an OData API. To control usage, an apikey affixed as an url parameter is required (I use a variation of this answer). I\'d love for my users to be able to explore the data exposed by the API usi

I run an OData API. To control usage, an apikey affixed as an url parameter is required (I use a variation of this answer). I'd love for my users to be able to explore the data exposed by the API using LINQPad. Ufortunately, there's no way to tell LINQPad to stick the apikey parameter to the end of query urls.

Are there any good suggestions for how to resolve this (and I'd really li开发者_运维问答ke to keep the apikey system).


If the api key were passed in the headers, you could do this:

SendingRequest += (sender, args) => args.RequestHeaders.Add ("apikey", "foo");

Customers.Take(10).Dump();

However, this won't have an effect when LINQPad fetches metadata. It also won't help you if you need to append the api key to the query string (which seems to be what you want).


@LinqPad
Customers.AddQueryOption("apikey", "").Take(10)
0

精彩评论

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