Skip to content

Allow custom content type for JSON body #189

@mgirlich

Description

@mgirlich

The content type is simply overwritten when using req_body_json()

library(httr2)

request("http://httpbin.org/404") |> 
  req_body_json(data.frame(x = 1)) |> 
  req_headers(`content-type` = "blub") |> 
  req_dry_run()
#> POST /404 HTTP/1.1
#> Host: httpbin.org
#> User-Agent: httr2/0.2.2.9000 r-curl/4.3.3 libcurl/7.85.0
#> Accept: */*
#> Accept-Encoding: deflate, gzip
#> Content-Type: application/json
#> Content-Length: 9
#> 
#> [{"x":1}]

Created on 2023-01-09 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    body 🕺featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions