Skip to content

Bugfix: Set JSON content type when getting token#64

Merged
ptz0n merged 3 commits intomasterfrom
bugfix/get-token-request-content-type
Feb 9, 2026
Merged

Bugfix: Set JSON content type when getting token#64
ptz0n merged 3 commits intomasterfrom
bugfix/get-token-request-content-type

Conversation

@ptz0n
Copy link
Owner

@ptz0n ptz0n commented Feb 9, 2026

What's the problem?

When calling getToken, Verisure API responds with:

HTTP: 415 - Unsupported Media Type

What's changed?

Pass the correct Content-Type header and valid JSON body for the request.

How can this be verified?

Tested using steps in README.

Fixes: #63

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Verisure login token acquisition failing with 415 Unsupported Media Type by ensuring the /auth/login request includes a JSON payload.

Changes:

  • Add an explicit (empty) request body to the /auth/login call to avoid an empty-body request.
  • Document intent inline next to the request config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

index.js Outdated
let authRequest = {
method: 'post',
url: '/auth/login',
data: {}, // Make sure it's content-type application/json.
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is a behavioral fix for the login request (body + media type). The existing Jest/Nock tests for getToken() don't assert request body or Content-Type, so this regression could slip back in. Add/adjust a test to validate that /auth/login is called with a JSON body (e.g., {}) and Content-Type: application/json.

Copilot uses AI. Check for mistakes.
ptz0n and others added 2 commits February 9, 2026 21:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ptz0n ptz0n merged commit 9fbe6b4 into master Feb 9, 2026
7 checks passed
@ptz0n ptz0n deleted the bugfix/get-token-request-content-type branch February 9, 2026 20:19
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

Successfully merging this pull request may close these issues.

/auth/login returns 415 Unsupported Media Type when request has Content-Type but empty body (Content-Length: 0)

2 participants