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

Unable to generate api token via API browser #2668

Closed
hc4 opened this issue Aug 11, 2016 · 3 comments
Closed

Unable to generate api token via API browser #2668

hc4 opened this issue Aug 11, 2016 · 3 comments
Assignees
Milestone

Comments

@hc4
Copy link
Contributor

hc4 commented Aug 11, 2016

Trying to create token using api browser.
But error returned:

{
  "type": "ApiError",
  "message": "HTTP 415 Unsupported Media Type"
}

Looks like the problem is in Content-Type header of request:
Content-Type:text/plain;charset=UTF-8

But according to sources Users api consumes json:

@RequiresAuthentication
@Path("/users")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Api(value = "Users", description = "User accounts")
public class UsersResource extends RestResource {

and generateNewToken api doesn't have consumes attribute at all.

Your Environment

  • Graylog Version: 2.1.0-beta.3-SNAPSHOT+8d14878
@joschi
Copy link
Contributor

joschi commented Aug 11, 2016

@joschi joschi closed this as completed Aug 11, 2016
@hc4
Copy link
Contributor Author

hc4 commented Aug 11, 2016

Curl works, if you will not add tag Content-Type.
But api browser generates request with content-type plaintext, which brokes api.

This request works fine:
curl -u ***:session -X POST "http://graylog/users/***/tokens/***"

But this not:

curl -u ***:session -X POST -H "Content-Type:text/plain;charset=UTF-8" "http://graylog/users/***/tokens/***"
{"type":"ApiError","message":"HTTP 415 Unsupported Media Type"}

@bernd bernd changed the title Unable to generate api token Unable to generate api token via API browser Aug 11, 2016
@bernd
Copy link
Member

bernd commented Aug 11, 2016

I updated the title and re-opened the issue.

@bernd bernd reopened this Aug 11, 2016
@bernd bernd added the bug label Aug 11, 2016
@bernd bernd added this to the 2.1.0 milestone Aug 15, 2016
@bernd bernd self-assigned this Aug 16, 2016
bernd added a commit that referenced this issue Aug 16, 2016
…owser

This forces the swagger API browser to use a Content-Type of
application/json.

Fixes #2668
joschi pushed a commit that referenced this issue Aug 16, 2016
* Add defaultValue param from ApiParam and DefaultValue annotations
* Add defaultValue to @ApiParam in RolesResource
* Add placeholder param to make it possible to create token from API browser

This forces the swagger API browser to use Content-Type: application/json

Fixes #2668
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants