I am trying to get data from a website (using API)using R. I got data using httr/POST and did some analysis. Recently, I found R was not giving me any data for some specific parameters but for the same parameters using terminal curl and Python/POST, I had some data (which are same). I am wondering what am I missing in case of R. Please see below what I am using (where myurl is the secret api address). Thanks in advance for your help.
In terminal:
This is defined in API manual and I wrote it accordingly.
curl myurl -d "timeMin= 965192400000" -d "timeMax=1533186000000" -d studentId=117
Same result if I used
curl -X POST myurl -d timeMin=965192400000 -d timeMax=1533186000000 -d studentId=117
or
curl -X POST myurl -d timeMin=965192400000 -d timeMax=1533186000000 -d studentId="117"
In R:
res <- POST(myurl, body = list(timeMin = 965192400000, timeMax = 1533186000000, studentId = "117" ),encode = c("form"))
Then I used res$content
, rawToChar
and fromJSON
In Python:
res = requests.post(myurl, data=[
('timeMin', 965192400000),
('timeMax',1533186000000 ),
('studentId', 117)])
Then I used json.loads
on response.text
and made it python dataframe.