Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

microsoft excel can not parse this odata format? #8

Open
EagleSmith opened this issue Jun 27, 2019 · 6 comments
Open

microsoft excel can not parse this odata format? #8

EagleSmith opened this issue Jun 27, 2019 · 6 comments

Comments

@EagleSmith
Copy link

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

@EagleSmith
Copy link
Author

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

@JocaPC
Copy link
Owner

JocaPC commented Jun 27, 2019

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.

  • Try to use version 0.5.1 with bug-fix and try again.
  • If this don't help or if you want to try it with the current version try to pass Metadata.MINIMAL parameter to OData request (depending what function you use). The bug with Content-type should not happen if you use minimal format.
  • Make sure that you use the latest version of necessary connector for Excel. When I browse for this error message I see that people resolved it by installing the latest version of WCF clients - maybe the same issues is here.

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
Copy link

Rich-AU commented May 14, 2020

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
Copy link
Owner

JocaPC commented May 16, 2020

@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:

  • Add root actions that returns OData service metadata based on the list of tables that should be exposed.
  • Setup metadata that will return XML metadata document that returns metadata information about the entities.

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
Copy link
Owner

JocaPC commented May 17, 2020

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

@Rich-AU
Copy link

Rich-AU commented May 18, 2020

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants