I start this new thread as a continuation of the comments in: Consume the Odata service and get the result in JSON
The problem I ran into is that I upgraded to wcf data services 5.5 and wcf client tools 5.3, as recommended in the thread. And I'm trying to execute a simple post for the following JayStorm service: https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/
I created a client service link in .Net and run the following code:
using Microsoft.Data.Edm; using Microsoft.Data.Edm.Csdl; using Microsoft.Data.Edm.Validation; using Microsoft.Data.OData; using System; using System.Collections.Generic; using System.Linq; using System.Spatial; using System.Text; using System.Threading.Tasks; using System.Xml; namespace AirportDBDataImporter { class Program { static void Main(string[] args) { var url = "https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/"; var db = new AirportDB.mydatabaseService(new Uri(url)); var xmlTextReader = new XmlTextReader(url+"$metadata"); IEdmModel edmModel = null; IEnumerable<EdmError> errors = null; if (EdmxReader.TryParse(xmlTextReader, out edmModel, out errors)) { } db.Format.UseJson(edmModel);
The EdmxReader part is necessary because an exception is thrown without it and without the UseJson () parameter, because the service is not fully compatible with odata v3. With this approach, SaveChanges () still throws an exception, but the airport record is actually inserted into the database and the returned information for the record (from JayStorm), since it contains the root property ādā of the old school style, it causes a parsing exception and the exception is thrown in second part of SaveChanges ().
My question is: is there anything I can do for this to completely fill out the JayStorm message? It seems not like the new wcf client no longer supports the old verbose json (which, it seems to me, comes from "d"?).
EDIT: Here is the original POST data from the violinist:
POST https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/Airport HTTP/1.1 DataServiceVersion: 3.0;NetFx MaxDataServiceVersion: 3.0;NetFx Content-Type: application/json;odata=minimalmetadata Accept: application/json;odata=minimalmetadata Accept-Charset: UTF-8 User-Agent: Microsoft ADO.NET Data Services Host: open.jaystack.net Content-Length: 196 Expect: 100-continue {"odata.type":"mydatabase.Airport","Abbrev":"Foo","GeoLocation":{"type":"Point","coordinates":[-176.64603,51.87796],"crs":{"type":"name","properties":{"name":"EPSG:4326"}}},"id":null,"Name":"Bar"}
Here is the response of the source data from the violinist:
HTTP/1.1 201 Created Server: nginx/1.4.1 Date: Fri, 21 Jun 2013 15:07:40 GMT Content-Type: application/json;odata=verbose;charset=utf-8;charset=UTF-8 Content-Length: 574 Connection: keep-alive X-Powered-By: Express Access-Control-Allow-Origin: open.jaystack.net Access-Control-Allow-Headers: X-PINGOTHER, Content-Type, MaxDataServiceVersion, DataServiceVersion, Authorization, X-Domain, X-Requested-With Access-Control-Allow-Method: POST Access-Control-Allow-Methods: OPTIONS, GET, HEAD, POST, MERGE, PATCH, DELETE, PUT Access-Control-Allow-Credentials: true location: https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/Airport('NTFjNDZjM2MyMjg1Y2FiNjMzMDAwMDAx') Set-Cookie: connect.sid=s%3AvwHQXjoJQO3VUxJdE2jrQ3ja.A4tG9Bv4XTg1gS5xAVgxMyWXJYrV6DULf3xWvj1Uhq8; Path=/; HttpOnly {"d":{"__metadata":{"type":"mydatabase.Airport","id":"https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/Airport('NTFjNDZjM2MyMjg1Y2FiNjMzMDAwMDAx')","uri":"https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/Airport('NTFjNDZjM2MyMjg1Y2FiNjMzMDAwMDAx')"},"Name":"Bar","Abbrev":"Foo","GeoLocation":{"type":"Point","coordinates":[-176.64603,51.87796],"crs":{"properties":{"name":"EPSG:4326"},"type":"name"}},"id":"NTFjNDZjM2MyMjg1Y2FiNjMzMDAwMDAx"}}
thanks