Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

content_type

Set content-type and accept headers.


Description

These are convenient wrappers aroud add_headers().

Usage

content_type(type)

content_type_json()

content_type_xml()

accept(type)

accept_json()

accept_xml()

Arguments

type

A mime type or a file extension. If a file extension (i.e. starts with .) will guess the mime type using mime::guess_type().

Details

accept_json/accept_xml and content_type_json/content_type_xml are useful shortcuts to ask for json or xml responses or tell the server you are sending json/xml.

Examples

GET("http://httpbin.org/headers")

GET("http://httpbin.org/headers", accept_json())
GET("http://httpbin.org/headers", accept("text/csv"))
GET("http://httpbin.org/headers", accept(".doc"))

GET("http://httpbin.org/headers", content_type_xml())
GET("http://httpbin.org/headers", content_type("text/csv"))
GET("http://httpbin.org/headers", content_type(".xml"))

httr

Tools for Working with URLs and HTTP

v1.4.2
MIT + file LICENSE
Authors
Hadley Wickham [aut, cre], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.