odata

OData in Web API Doesn't Follow OData Standard Specs

两盒软妹~` 提交于 2019-12-24 17:40:53
问题 First of, the standard spec for OData response looks like: { "d" : { "results": [ { "__metadata": { "uri": "http://demos/Orders(10248)", "type": "SampleModel.Order" }, "ProductId": 10248, "Name": "Vgnon" } ], "__count": "1" } } But, in Web API (using EntitySetController), the OData response looks like: { "odata.metadata":"http://localhost:43111/api/$metadata#Products", "odata.count":"1", "value": [ { "ProductId":2, "CreatedDate":"2013-06-10T23:53:26", "CreatedBy":0,"Name":"Camera" } ] }

Adding JsessionID in Request Header

元气小坏坏 提交于 2019-12-24 14:30:25
问题 I have got the Jsessionid and I would like to add it to the Header, but I do not know where to add it. Cookie jSessionID = client.ResponseCookies["JSESSIONID"]; if (jSessionID != null) { // JSESSIONID sessionid = jSessionID.Value; var settings = new ODataClientSettings() { UrlBase = "MyURL" }; settings.BeforeRequest += delegate(HttpRequestMessage request) { String aux = String.Join(":", new String[] {"admin", "admin" }); var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(aux); request

How to declare a parameter as prefix on OData

北城以北 提交于 2019-12-24 14:03:55
问题 Using a normal ApiController in WebApi, I made the following code to define a dynamic map route template for every ApiControllers: config.Routes.MapHttpRoute( name: "Sample", routeTemplate: "{sessionId}/{controller}" ); I want to achieve a similar behaviour but for every ODataController. I've tried the following code, but it doesn't work: config.MapODataServiceRoute( routeName: "HSODataRoute", routePrefix: "{sessionId}/", model: GetEdmModel()); Any idea how this is made in OData? I'm kinda

WebApi & Odata - suitable for file management?

旧时模样 提交于 2019-12-24 13:55:32
问题 I am moving most / all of my API in a project over to Odata from "pure" WCF and using an OWIN hosted Odata enpoint for this. The one element I am stuck with at the moment are files. I have 2 areas where I need to upload a ZIP file to the server for processing. In one case that is attached to an Entity (called a "Repository") and contains binary content that is not exposed via Odata (it is just uploaded). In the other hand this is for an unbound action and the ZIP file contains configuration

Performing OData methods with Edm.DateTime as part of primary keys

ぃ、小莉子 提交于 2019-12-24 13:33:45
问题 I have the problem, that I want to update a table via HTTP-request. But I always get an error-message on the Edm.DateTime attributes in the table. Error: Invalid URI-Segment '00:00',ValdTo=datetime'2019-04-03T00:00:00')'"} Even the value is already converted to Edm.DateTime. valdfrom_edit = encodeURI(sap.ui.model.odata.ODataUtils.formatValue(new Date(values.ValdFrom), "Edm.DateTime")); var update = "/ZSCORDERINGSet(Mandt='010',Vkorg='" + vkorg_Edit + "',ZzscSpSas='" + suppl_edit + "',ValdFrom

Format of DateTimeOffset in OData

冷暖自知 提交于 2019-12-24 12:53:48
问题 I have two JavaScript Date objects. I need to do an OData query between these two Date objects. The information I'm querying has a field called createDate which is a DateTimeOffset . From my understanding, I can do something like this: entities?filter=((createDate ge [Date1]) and (createDate le [Date2])) My question is: What format is a DateTimeOffset? How do I convert a JavaScript Date object to DateTimeOffset format? Thank you! 回答1: First it depends your version of OData service. OData V4

How to make a Odata batch call in karate

南楼画角 提交于 2019-12-24 12:33:25
问题 I need to make Odata call to fech the results from downsream APIs. I am using karate to test our APIs. But now i need to fech the data from downstream APIand compare it with our APIs result. My problem is downstream APIs are Odata request. Can i make Odata batch request from karate. if yes how? Request header is: Content-Type = 'multipart/mixed;boundary=batch_01' and Request body is: --batch_01 Content-Type: application/http Content-Transfer-Encoding: binary GET test(test1='ABC',test2='12345'

How to make a Odata batch call in karate

99封情书 提交于 2019-12-24 12:27:14
问题 I need to make Odata call to fech the results from downsream APIs. I am using karate to test our APIs. But now i need to fech the data from downstream APIand compare it with our APIs result. My problem is downstream APIs are Odata request. Can i make Odata batch request from karate. if yes how? Request header is: Content-Type = 'multipart/mixed;boundary=batch_01' and Request body is: --batch_01 Content-Type: application/http Content-Transfer-Encoding: binary GET test(test1='ABC',test2='12345'

OData query in swagger ui

ⅰ亾dé卋堺 提交于 2019-12-24 11:27:26
问题 I was checking out the following tutorial: http://blogs.msdn.com/b/martinkearn/archive/2015/03/10/using-odata-query-syntax-with-web-api.aspx And I was curious if there was support in swagger ui somehow to show the query parameters. Essentially I wanted all calls tagged with [EnableQueryAttribute] attribute to have swagger ui for inputting query parameters and I don't want to add these parameters to the method call I still want them to be in the URL and pulled out for the Owin context. Any

Can I use a complex datatype with an EF-provided WCF Data Services without telling EF about it?

旧巷老猫 提交于 2019-12-24 10:49:37
问题 I am using an Entity Framework-provided WCF DataService to expose an OData endpoint. I want to create a Service Operation that returns a new type. But I get: The exception message is 'Unable to load metadata for return type 'System.Linq.IQueryable 1[MyNamespace+MyNewType]' of method 'System.Linq.IQueryable 1[MyNamespace+MyNewType] FlightHours()'.'. See server logs for more details. How can I let the DataService know I want it to grok MyNewType? Do I have to hackily make a fake entity on the