Skip to content

Retrieve a Collection API endpoint uses request content-type instead of accept header #178

Description

@carbontwelve

Describe the bug

When using the Retrieve a Collection API endpoint as documented here I notice that when sending a request with the Accept header correctly set to application/json the server was incorrectly returning Content-Type:text/html.

Upon looking at the source code I can see this bug is seemingly due to the following line: https://github.com/writeas/writefreely/blob/master/collections.go#L321

Steps to reproduce (if necessary)

Steps to reproduce the behavior:

  1. Request the GET /api/collections/{COLLECTION_ALIAS} API endpoint with Accept header set for application/json
  2. Server responds with HTML.

Expected behavior

The request is stating it accepts json the server should respond with content type json or HTTP 415 Unsupported Media Type if not supported. Given that the API supports returning JSON it should have responded with JSON.

The following line https://github.com/writeas/writefreely/blob/master/collections.go#L321 potentially needs amending to include the Accept header as well.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions