JocaPC / sql-server-rest-api

Other
67 stars 16 forks source link

microsoft excel can not parse this odata format? #8

Open EagleSmith opened 5 years ago

EagleSmith commented 5 years ago

return data: { "Id": "0101010019 ", "Barcode": "00182", "Name": "灏忚嫤鑿\ufffd", "ItemClsId": "200201 " } microsoft can't parse this data ?

EagleSmith commented 5 years ago

result message : A missing or empty content type header was found when trying to read a message. The content type header is required

JocaPC commented 5 years ago

There is a bug that might cause this and it is fixed in NuGet version 5.1: https://www.nuget.org/packages/MsSql.RestApi/0.5.1

However, I have not reproduced your issue.

If nothing helps, could you provide more details? It would be helpful if you could call the OData service directly via browser and see what properties are missing.

I'm not an expert for Excel OData but not that it might be possible that it requires metadata-full or some specific version of OData (for example v3), or maybe XML version instead of JSON, and that this is causing the issue.

Rich-AU commented 4 years ago

I experience similar problem and worked out Excel (and power BI desktop as well) requires proper Odata Service document and cdsl metadata to get the data structure first, which aren't provided by this library.

@JocaPC, is there any plan to enhance this library to provide Odata Service Document and metadata?

JocaPC commented 4 years ago

@Rich-AU @EagleSmith - if you are still interested for this here is example that you can try: https://github.com/JocaPC/sql-server-rest-api/tree/belgrade-odata-min-metadata-api

This sample exposes system views sys.objects, sys.columns, and sys.parameters as OData api and you can add more tables there.

The challenge with Excel is that it requires at least OData with min metadata. My service returns no-metadata by default because this is easiest to configure. To enable excel to read data from OData you need to do two additional things:

If URL don't match excel will fail. See setup instructions here: https://github.com/JocaPC/sql-server-rest-api/blob/belgrade-odata-min-metadata-api/README.md

I would be happy to try to make setup experience easier if this works fine.

Please let me know does it works for your.

JocaPC commented 4 years ago

Here is example of OData controller that can provide OData content to Excel and LinqPad in main branch.

Rich-AU commented 4 years ago

@JocaPC , that's really great!

Currently I am working on an example that can dynamically adding controller actions (tables/views) based on configurations in the appsetting.json file - like this : "Customer": { "Enabled": "true", "schema": "SalesLT", "table": "Customer", "Columns": "", "relatedtable": "CustomerAddress", "relatedschema": "SalesLT", "relatedJoin": "SalesLT.Customer.CustomerID=SalesLT.CustomerAddress.CustomerID", "relatedcolumns": "" }

The only thing I still need to work on is to generate proper service document and metadata, your example above does give me a clear direction, thanks a lot!