Reputation: 1
I am trying to read the output from odata services in json format. but i am getting the error message as
"The response payload is a not a valid response payload. Please make sure that the top level element is a valid Atom or JSON element or belongs to 'http://schemas.microsoft.com/ado/2007/08/dataservices' namespace".
NorthwindEntities dc = new NorthwindEntities(new Uri("http://services.odata.org/V3/Northwind/Northwind.svc/"),DataServiceProtocolVersion.V3);
dc.Format.UseJson(new EdmModel());
DataServiceQuery<Product> query = (DataServiceQuery<Product>)from o in dc.Products
where o.UnitPrice > 0
select o; query.execute();
{"odata.metadata":"http://services.odata.org/V3/Northwind/Northwind.svc/$metadata#Products","value":[{"ProductID":24,"ProductName":"Guaran\u00e1 Fant\u00e1stica","SupplierID":10,"CategoryID":1,"QuantityPerUnit":"12 - 355 ml cans","UnitPrice":"4.5000","UnitsInStock":20,"UnitsOnOrder":0,"ReorderLevel":0,"Discontinued":true},{"ProductID":33,"ProductName":"Geitost","SupplierID":15,"CategoryID":4,"QuantityPerUnit":"500 g","UnitPrice":"2.5000","UnitsInStock":112,"UnitsOnOrder":0,"ReorderLevel":20,"Discontinued":false}]}
Upvotes: 0
Views: 1408
Reputation: 65
You JSON string is not valid as it has a property name with a '.' in it. odata.metadata cannot be resolved.
If you changed that to odata_metadata, or possible went with the solution provided here: enter link description here
Upvotes: 0