Jump to content

Failed to load API definition


mchahn

Recommended Posts

When I click on the api button on my dashboard I get an error page titled "Failed to load API definition".  The details are below.  Any help would be appreciated.

 

Fetch error

Failed to fetch http://xxx.com:8096/emby/openapi
 

Fetch error

Possible cross-origin (CORS) issue? The URL origin (http://xxx.com:8096) does not match the page (http://swagger.emby.media). Check the server returns the correct 'Access-Control-Allow-*' headers.

 

Link to comment
Share on other sites

Hmmm.  I enabled https in my server and tested it at https://my-domain:8920.  It loaded fine so I know my https setup works.   When I used the api button again it got  the same error.  Any ideas?

 

Link to comment
Share on other sites

Happy2Play
37 minutes ago, mchahn said:

Hmmm.  I enabled https in my server and tested it at https://my-domain:8920.  It loaded fine so I know my https setup works.   When I used the api button again it got  the same error.  Any ideas?

 

Are you actually logged in with your https url when you click the API link?  Works fine for me as you get https swagger with my https address.

image.thumb.png.2a1506b6effdf0406aa069b3e78b9ef5.png

If logged in via LAN you can only use API link with localhost but have to manually apply https to Swagger as it is currently hard coded http. (needs adjusted per my request in other topic).

Or adjust the browser flags.

Link to comment
Share on other sites

> Are you actually logged in with your https url when you click the API link

Yes, I tried it with and without https.  The box at the top of the swagger page matches where I came from.  I.e. it shows https://xxx.com:8920/emby/openapi when coming from https and http://xxx.com:8096/emby/openapi with http.  In either case I get the definition error.

If logged in via LAN you can only use API link with localhost but have to manually apply https to Swagger

I'm sorry but I'm having trouble parsing that.  I am coming from a lan.   I don't understand what you mean by using an API link with localhost.  Do you mean to run emby-server from localhost?  My emby-server is on a headless linux server.  I guess I could install a local copy of emby-server on my windows machine but that would be a bit of work.

> Or adjust the browser flags.

Which flag would that be?  I found your other thread and I saw mention of a browser policy, but I'm not familiar with what a browser policy is.  When I googled it there was only mention of enterprise stuff.  I went to chrome://flags and put InsecurePrivateNetworkRequestsAllowed in the search box.  Nothing came up.

I am currently just updating the dashboard.js.

Do you do that to change the default swagger url in that box at the top of the page to an https link?   My url is already the https version.

I'm sorry for all the questions.  I appreciate your help.  I can proceed with development without swagger but it would be harder.

Link to comment
Share on other sites

You can pretty much ignore that last messy post.  I got it working by changing the swagger url in the browser url bar from http to https.  Nothing else in the url changed.

So I guess turning on https support in emby-server and then changing the swagger url is all that was needed,

Thanks again.

Link to comment
Share on other sites

Another question, this time about how to use the swagger page.  I can't figure out where to put in my api key.  I know how to put it in a url but there doesn't seem to be anything about a url on the swagger page. The authorize button just directs me to my emby api-keys.  I googled like crazy and I can't find anything general about authorizing in swagger.  Help please?

Link to comment
Share on other sites

Happy2Play
28 minutes ago, mchahn said:

I know how to put it in a url but there doesn't seem to be anything about a url on the swagger page.

What do you mean?  I applied a custom api key to url and everything worked that I tested.  So a bookmarked url does work with custom generated api key.

But since the /login endpoint is not exposed, I am guessing you cannot use the authentication button.

Link to comment
Share on other sites

>   I applied a custom api key to url 

Ah.  It didn't occur to me to edit the big url at the top of the page.  That has gotten me further. 

Now i'm up to the infamous error: "Value cannot be null. (Parameter 'appName')" when trying AuthenticateUserByName.   I've scoured this thread about the problem, https://emby.media/community/index.php?/topic/85498-value-cannot-be-null-parameter-appname/,  I couldn't tell if anyone in the thread ever got swagger to work.  They did succeed using other tools. 

I set the authentication header to ...

       UserId="894c752d448f45a3a1260ccaabd0adff", Client="MyClient", Device="myDevice", DeviceId="123456", Version="1.0.0"

... but I'm still getting that error.   How did you get past the problem?

 

Link to comment
Share on other sites

rbjtech

Swagger works on remote hosts (incl LAN) only over https.   Both swagger itself and the remote host need to be https.

https://swagger.emby.media/?url=https://my.emby.com:8920

Swagger does also allow connection to a http host but it can only be 'localhost'.  

https://swagger.emby.media/?url=http://localhost:8096

If your host is remote (even on a LAN), then the only way to use 'localhost' is to remote desktop onto the host and run it from there.

Link to comment
Share on other sites

I got past all the https problems earlier.  This was all discussed at the beginning of this thread. 

I'm going to at least temporarily give up on swagger and just go directly to accessing the emby server from my web page.  Swagger can at least be a source of documentation.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...