Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsupported media type #3

Open
opensas opened this issue May 2, 2019 · 3 comments
Open

unsupported media type #3

opensas opened this issue May 2, 2019 · 3 comments

Comments

@opensas
Copy link

opensas commented May 2, 2019

I tried to test the app running

$ curl -d "username=test&password=test" -X POST http://localhost:4000/users/authenticate
{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.13","title":"Unsupported Media Type","status":415,"traceId":"0HLMEPV7RSATF:00000001"}

Same error if I try with vscode rest client like this:

POST http://localhost:4000/users/authenticate
accept: application/json
content-type: application/x-www-form-urlencoded

username=test
&password=test

I get:

HTTP/1.1 415 Unsupported Media Type
Connection: close
Date: Thu, 02 May 2019 07:36:26 GMT
Content-Type: application/problem+json; charset=utf-8
Server: Kestrel
Transfer-Encoding: chunked

{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.13",
  "title": "Unsupported Media Type",
  "status": 415,
  "traceId": "0HLMEPV7RSATG:00000001"
}

I think it would be very useful to add to the docs a curl command line to test the app

@opensas
Copy link
Author

opensas commented May 2, 2019

I downloaded the vue app, and inspecting it I realized that it expects the values as a json in the body.

I tried to change it to accept form parameters, with no luck

        [AllowAnonymous]
        [HttpPost("authenticate")]
        [Consumes("application/x-www-form-urlencoded")]
        public IActionResult Authenticate([FromBody]User userParam)

I keep getting the same error, any idea?

@Linshiqi
Copy link

Linshiqi commented Jun 26, 2019

@opensas I use httpie instead of curl, Just post data like get style:
http http://locahost:4000/users/authenticate username=test password=test
this works fine for me, good luck

@ajonesrock
Copy link

change
public IActionResult Authenticate([FromBody]User userParam)
to
public IActionResult Authenticate([FromForm]User userParam)

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

No branches or pull requests

3 participants