Skip to content

Session "Content-Type" header overriden by RequestBlob.headers #24

@liancheng

Description

@liancheng

Hit this issue while playing with the create issue JIRA REST API:

val session = requests.Session(
  auth = user -> password,
  headers = Map("Content-Type" -> "application/json")
)

val fields: ujson.Obj = ???

val response = session.post(
  url = "...",
  data = ujson.Obj("fields" -> ujson.Obj.from(fields))
)

The above snippet always got a 415 Unsupported Media Type error. Setting the "Content-Type" header explicitly while posting the requests fixes this issue:

val response = session.post(
  url = "...",
  headers = Map("Content-Type" -> "application/json")
  data = ujson.Obj("fields" -> ujson.Obj.from(fields)).render()
)

Further debugging showed that the "Content-Type: text/plain" header generated by StringRequestBlob took a higher precedence than the one defined in session.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions