clerk / clerk/clerk-sdk-java

Create Session => Content-Type is unsupported. You should use application/json instead

Open
#102 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
48
Forks
23
Avg merge
4h 12m
Merged PRs (30d)
1

Description

https://github.com/clerk/clerk-sdk-java/blob/main/docs/sdks/sessions/README.md#create causes:

"Content-Type is unsupported","long_message":"Content-Type is unsupported. You should use application/json instead.",

ClerksTest > clerkTestingToken() FAILED
    SDKError[requestMethod=POST, requestUri=https://api.clerk.com/v1/sessions/sess_39zfw909Yvg9iEfgxVGM1IC3iDf/tokens, code=415, responseHeaders={:status=[415], cf-cache-status=[DYNAMIC], cf-ray=[9d18d52f1b327a85-ZRH], clerk-api-version=[2025-11-10], content-length=[228], content-type=[application/json], date=[Sat, 21 Feb 2026 20:00:56 GMT], server=[cloudflare], set-cookie=[__cf_bm=n3QrywajChUuzq95LHZs9LQEGEAbiBUXSOnsvYOzg7E-1771704056-1.0.1.1-2Cbe4GAqRt42WHTgNj.ovn4H2GxUhfdHN_hWRcVpP1gGK49gGr_70K97pYTlGZ3GQbzi0uqCtHDIfHWH_XdCE1PdEMlXa0IpI83kYHZvyXE; path=/; expires=Sat, 21-Feb-26 20:30:56 GMT; domain=.api.clerk.com; HttpOnly; Secure; SameSite=None, _cfuvid=SClopz.8P6zvAeeE1aAfZADl7YHmmvqBWnJxWe0nv1c-1771704056345-0.0.1.1-604800000; path=/; domain=.api.clerk.com; HttpOnly; Secure; SameSite=None], x-cfworker=[1], x-clerk-trace-id=[ba15286b6af46c65de478848a7c3cb1f], x-cloud-trace-context=[ba15286b6af46c65de478848a7c3cb1f]}, message=API error occurred, body={"errors":[{"message":"Content-Type is unsupported","long_message":"Content-Type  is unsupported. You should use application/json instead.","code":"unsupported_content_type"}],"clerk_trace_id":"ba15286b6af46c65de478848a7c3cb1f"}]
        at app//com.clerk.backend_api.models.errors.SDKError.from(SDKError.java:35)
        at app//com.clerk.backend_api.models.errors.SDKError.from(SDKError.java:29)
        at app//com.clerk.backend_api.operations.CreateSessionToken$Sync.handleResponse(CreateSessionToken.java:217)
        at app//com.clerk.backend_api.operations.CreateSessionToken$Sync.handleResponse(CreateSessionToken.java:133)
        at app//com.clerk.backend_api.models.operations.CreateSessionTokenRequestBuilder.call(CreateSessionTokenRequestBuilder.java:77)
        at app//dev.enola.common.auth.clerk.Clerks.clerkTestingToken(Clerks.java:100)
        at app//dev.enola.common.auth.clerk.ClerksTest.clerkTestingToken(ClerksTest.java:14)

from:

public static String clerkTestingToken() {
        Clerk clerk = Clerk.builder().bearerAuth(CLERK_SECRET_KEY).build();
        var testUserID = "user_...";
        var sessionID =
                clerk.sessions()
                        .create()
                        .request(new CreateSessionRequestBody(testUserID))
                        .call()
                        .session()
                        .get()
                        .id();
        return clerk.sessions()
                .createToken()
                .sessionId(sessionID)
                .call()
                .object()
                .get()
                .jwt()
                .get();
        // TODO Return a Closeable where close() revokes the token
    }

Intended to be use in an integration test.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with CreateSessionTokenRequestBuilder.call and CreateSessionToken.java, where the failing stack trace shows the token request is built and handled. Inspect how the request Content-Type is set, then rerun ClerksTest.clerkTestingToken as the integration check; done means the session token request uses application/json without the 415 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.