Skip to content

Plex url not correct resulting in 404 #22

Description

@Deff3x

When trying to retrieve the User details for the display name using client.plex.getUserDetails() it is returning a 404 response due to a bad request url.

When instantiating I am providing the following:

const client = new PlexAPI({
  accessToken,
  xPlexClientIdentifier: uuid,
  ip: '192.168.0.53',
  port: '32400',
  protocol: 'http',
})

const test = await client.plex.getUserDetails()
console.log(test)

Results:

SDKError: API error occurred: Status 404 Content-Type application/json; charset=utf-8 Body 
{"status":404,"error":"Not Found"}
{
  rawResponse: Response {
    status: 404,
    statusText: 'Not Found',
    headers: Headers {
      date: 'Wed, 04 Sep 2024 20:49:31 GMT',
      'content-type': 'application/json; charset=utf-8',
      'transfer-encoding': 'chunked',
      connection: 'keep-alive',
      'x-request-id': '4ceb9337c8be874ded4d20c8dfa4ba32',
      'x-runtime': '0.002691',
      'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
      'referrer-policy': 'origin-when-cross-origin',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'SAMEORIGIN',
      'x-xss-protection': '1; mode=block',
      vary: 'Origin',
      'content-encoding': 'gzip'
    },
    body: ReadableStream { locked: true, state: 'closed', supportsBYOB: true },
    bodyUsed: true,
    ok: false,
    redirected: false,
    type: 'basic',
    url: 'https://plex.tv/api/v2user'
  },
  body: '{"status":404,"error":"Not Found"}',
  statusCode: 404,
  contentType: 'application/json; charset=utf-8'
}

As you can see from above the url is set to url: 'https://plex.tv/api/v2user'.

I am receiving similar results with *.plex.getUserFriends()

Fix for now is manually overriding the server url and including the ending forward slash / as follows:

const test = await client.plex.getUserDetails({
  serverURL: "https://plex.tv/api/v2/",
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions