I have the following request in Python. How can I rewrite this in R's httr package?
The thing I'm not sure about is how to translate the json and tuple equivalent in R.
import requests
cookies = {}
headers = {
'Host': 'mysejahtera.malaysia.gov.my',
'Accept': 'application/json',
'Connection': 'keep-alive',
'Content-Length': '77',
'Authorization': 'Basic N0ZFRkRCMTMtN0Q2MC00NEQxLUE5MTctM0',
'Content-Type': 'application/json',
'Accept-Language': 'en-MY;q=1, ms-MY;q=0.9',
'User-Agent': 'MySejahtera/1.0.36 (iPhone; iOS 14.6; Scale/2.00)',
}
params = (
('type', 'search'),
)
data = '[{"lat":3.003090,"lng":101.678300,"classification":"LOW_RISK_NS"}]'
response = requests.post('https://mysejahtera.malaysia.gov.my/register/api/nearby/hotspots', headers=headers, params=params, cookies=cookies, data=data)
response.json()
Here's an attempt. But still gives out 400 bad request
POST("https://mysejahtera.malaysia.gov.my/register/api/nearby/hotspots?type=search",
body = list(lat = 3.003090, lng = 101.678300, classification = 'LOW_RISK_NS'),
add_headers(Host= 'mysejahtera.malaysia.gov.my',
Accept= 'application/json',
Connection= 'keep-alive',
`Content-Length`= '77',
Authorization= 'Basic N0ZFRkRCMTMtN0Q2MC00NEQxLUE5MTctM0',
`Content-Type`= 'application/json',
`Accept-Language`= 'en-MY;q=1, ms-MY;q=0.9',
`User-Agent`= 'MySejahtera/1.0.36 (iPhone; iOS 14.6; Scale/2.00)'), verbose())
from R httr post with headers
No comments:
Post a Comment