Using RCurl with multiple quotes and parentheses

22 Views Asked by At

I am trying to get this API (that works in shell) to work within R:

curl -H 'Content-Type: text/json' -d '{"Symbols":["FLDB","APOE"]}' https://toppgene.cchmc.org/API/lookup

I followed this example and wrote this R studio:

library(RCurl)
library(RJSONIO)

postForm("https://toppgene.cchmc.org/API/lookup",
         .opts = list(postfields = toJSON(list(Symbols = "[", "FLDB", "APOE", "]")),
                      httpheader = c('Content-Type' = 'text/json')))

and I get an internal server error. I have all the packages installed and I don't think there is a syntax error.

Any help on this? Thanks.

1

There are 1 best solutions below

0
user2167741 On

Figured out the answer:

library(RCurl)
library(RJSONIO)

GS <- list("FLDB","APOE")

postForm("https://toppgene.cchmc.org/API/lookup",
                      .opts = list(postfields = toJSON(list(Symbols = GS),
                                   httpheader = c('Content-Type' = 'text/json')))