question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ktor with with mustache 415 Unsupported Media Type: POST

See original GitHub issue

Ktor Version

1.1.2

Ktor Engine Used(client or server and name)

netty

JVM Version, Operating System and Relevant Context

java version 10.0.2 mac os

Feedback

i built a small app to test mustache with ktor but when i try to post data using html form in mustache file .hbs file the post gave me an

415 Unsupported Media Type: POST when i try to recieve a typed json val param = call.receive<Quote>()

and also give me a null value when i try val param = call.receive<Parameters>() val author = param["author"]!! val qouteText = param["quoteText"]!!

and this is my html form

screen shot 2019-02-02 at 8 49 10 pm

` <form role="form" class="col-xs-3 text-center" style="width: 30%" action="/quotes" method="post" > <div class="form-group"> <label for="titleInput">Author</label> </div>

        <div class="form-group">
            <label for="quote">Quote</label>
            <br>
            <textarea class="form-control" id="quote" rows="3" required="required"></textarea>
        </div>
        <div class="text-center">
            <button type="submit" class="btn btn-primary mb-2 text-center">Confirm</button>
        </div>


    </form>`

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
thegeniusprogrammercommented, Sep 3, 2022

Add Header “Content-Type”: “application/json” while sending request in postman, and don’t forget to add ContentNegotiation plugin in your ktor project.

1reaction
Harin-Kaklotarcommented, Apr 22, 2022

Actually, this happens when we forgot to install ContentNegotiation with JSON. Don’t forget to add a dependency and plugin for serialization and request with the header “Content-Type”: “application/json”

Read more comments on GitHub >

github_iconTop Results From Across the Web

ktor with with mustache 415 Unsupported Media Type: POST
This issue was imported from GitHub issue: https://github.com/ktorio/ktor/issues/925. Ktor Version. 1.1.2. Ktor Engine Used(client or server and name).
Read more >
Ktor returns 415 from endpoints where receive() is used with ...
Firstly, ContentNegotiation feature works only for receiving custom objects from the payload of POST, PUT and PATCH requests:.
Read more >
UnsupportedMediaTypeException - ktor
HTTP status 415 Unsupported Media Type will be replied when this exception is thrown and not caught. Constructors Functions Properties ...
Read more >
Server-Side Kotlin with Ktor · API Post Endpoint
For the 415Unsupported Media Type error, sounds like there may be an issue with the request.json file that was created. What editor did...
Read more >
https://raw.githubusercontent.com/ktorio/ktor/mast...
... results in 400 Bad Request instead of 415 Unsupported Media type ... form post ([KTOR-3342](https://youtrack.jetbrains.com/issue/KTOR-3342)) * Ktor test ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found