Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

--user curl equivalent in httr

Tags:

curl

r

httr

This is, I presume, some really simple curl code that I am trying to translate into a httr format.

curl -X POST \
  --user '<email>:<password>' \
  --header 'user-key: <user_key>' \
  --url https://api.m.com/v1/clients

So far I have tried

library(httr)    
POST(url = "https://api.m.com/v1/clients",
                 add_headers('user-key' = "userkey",
                             user = 'email:password'))

But without success. Any hints on what is wrong here? Is there an httr equivalent to --user in the curl code?

like image 381
FilipW Avatar asked Jan 03 '23 19:01

FilipW


1 Answers

library(httr)  

username <- 'my_user_name'
password <- 'my_password'

POST(url = "https://api.m.com/v1/clients", 
                 config = authenticate(username, password), add_headers("Content-Type: application/json"),
                 body = upload_file('./my_file.json'),
                 encode = 'json')
like image 183
Rodrigo Araujo Avatar answered Jan 11 '23 15:01

Rodrigo Araujo