OData / ODataConnectedService

A Visual Studio extension for generating client code for OData Services
Other
79 stars 41 forks source link

Question about using OData CLI from within GitHub Actions: Fails with "(401) Unauthorized" exception #378

Closed pbru87 closed 7 months ago

pbru87 commented 7 months ago

I'm trying to use the OData CLI tool (version 0.1.0) from within a GitHub Actions' deployment workflow, but it always fails with a "(401) Unauthorized" exception.

Within the GitHub Actions workflow, I basically execute the following commands (which works perfectly on a local Windows machine).

$ dotnet tool install -g Microsoft.OData.Cli --version 0.1.0
$ odata-cli generate -m "https://example.com:7048/BC/api/BSSO/example/v2.0/$metadata" -h "Authorization:Basic MY-SECRET-TOKEN" -o "..\example-folder\Connected Services\OData Service" --upper-camel-case --ignore-unexpected-elements

This is the output shown to me from the GitHub action run:

You can invoke the tool using the following command: odata-cli Tool 'microsoft.odata.cli' (version '0.1.0') was successfully installed. The remote server returned an error: (401) Unauthorized.

I even tried an API request via Postman with the same OData endpoint URL and the same token. With Postman it also worked just fine.

Has anyone experienced a similar situation? Any thoughts? - Would be nice to get some feedback on this.

Thanks in advance!

Best regards, Patrick

gathogojr commented 7 months ago

Thank you @pbru87 for reporting the issue. Can you try to run the cli tool locally and see if it works?

pbru87 commented 7 months ago

Hi @gathogojr, thanks for your reply. With v0.1.0 it also fails locally under Ubuntu 22.04 as well as under Windows 10.

Actually, I was going to close this issue because I found the v0.2.1 on NuGet today, which solved my issue. I unfortunately oversaw that there is a newer version, because I only looked into this repo's releases section, where the v0.2.1 release is not listed.

Best regards, Patrick