https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
b

Benedikt Kaiser

03/23/2023, 2:36 PM
hi, i am currently testing kmm and i am building a small app with a simple api request generated with openapi generator. the get request was pretty straight forward now i am trying to implement a post request and i always get the error "java.lang.IllegalStateException: Fail to prepare request body for sending. " despite the correct declaration in the openapi file. does anybody know if i need to change the openapi file in order to work properly with ktor or if there is a special setting i need for the generation? Openapi file is in the thread
Copy code
openapi: 3.0.2
info:
  title: *****************
  version: 1.0.0
servers:
  - url: *******************
paths:
  /login:
    post:
      summary: User Login
      description: Logs in a user and returns a token.
      requestBody:
        description: User credentials for login
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserCredentials'
      responses:
        '200':
          $ref: '#/components/responses/AuthSuccessful'
        '401':
          $ref: '#/components/responses/InvalidCredentials'
Error: The body type is: class openapitools.client.models.UserCredentialsDto (Kotlin reflection is not available), with Content-Type: null.
i installed content-negotiation in the commonMain sourceSet
p

Pablichjenkov

03/23/2023, 2:47 PM
You might want to ask in #ktor too
b

Benedikt Kaiser

03/23/2023, 2:48 PM
thanks will do
7 Views