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

Cannot connect to ODATA v4 from MS Business Central via Visual Studio for Outh authentication #81

Open
Sarika-Sita opened this issue May 20, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Sarika-Sita
Copy link

I am unable to add the Reference for ODATA service published from MS Business Central.

Following is the message after pressing finish.

Adding service instance...
Adding Nuget Packages for OData V4...
Nuget Package "Microsoft.OData.Client" for OData V4 already installed.
Nuget Package "Microsoft.OData.Core" for OData V4 already installed.
Nuget Package "Microsoft.OData.Edm" for OData V4 already installed.
Nuget Package "Microsoft.Spatial" for OData V4 already installed.
Nuget Packages for OData V4 were installed.
Generating Client Proxy for OData V4...
Error:Adding Unchase OData Connected Service to the project failed: Failed to access the metadata document. The OData service requires authentication for accessing it. Please download the metadata, store it into a local file, and set the value of “MetadataDocumentUri” in the .odata.config file to the file path. After that, run custom tool again to generate the OData Client code.

Steps to reproduce

  1. Publish one page on web service page in Business Central
  2. Install Odata V4 connected service in Visual Studio
  3. Create VS project and add connected service with URL of web service.
  4. go to next.

It must connect with Web Service. But it is showing above error. I am following following MS document.

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/authenticate-web-services-using-oauth

I checked the issue in Github with below link as well but no help.

#35

@Sarika-Sita Sarika-Sita added the bug Something isn't working label May 20, 2022
@dazinator
Copy link

Looks pretty self explanatory to me.. it's saying it can't obtain the metadata from the odata service because the service requires authentication. If you browse to the metadata endpoint yourself to get the metadata document (you'll have to authenticate with the odata service) then save this document to a file, then run this extension and use the option to select the metadata from the file instead.

@HekiShavik
Copy link

If we could get the option to add a custom header to the $metadata call, it would solve this problem. The Microsoft OData Connected Service extension allows this.

This is off topic, but the MS extension has other problems related to BC though, which this extension shares because the generated code use the same change tracker that pushes the entire object instead of just the changed properties. 'id' is readonly..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants