I'm trying to extract the recipe data from Edamam API. All of my GET/POST requests fail.
I've tried to extract the data through Python, which works seamlessly but R gives "must not be NULL"
Here is the code:
library(httr)
library(jsonlite)
# Store the ID and Key in variables
APP_ID = "XXXXXX"
APP_KEY = "XXXXXXXXXX"
# Note: Those are not real ID and Key,
# Replace the string with your own ones that you recieved upon registration
# Setting up the request URL
api_endpoint = "https://api.edamam.com/api/recipes/v2"
url = paste0(api_endpoint, "?app_id=", APP_ID, "&app_key=", APP_KEY)
#Defining the header (as stated in the documentation)
headers = list(
`Content-type` = 'application/json'
)
#Defining the payload of the request (the data we actually want processed)
recipe = list(
`mealType` = 'breakfast'
)
#Submitting a POST request
tmp <- POST(url, body = recipe, encode = "json")
tmp <- GET(url)
tmp <- httr::POST(url, body = recipe, verbose(), content_type("application/json"))
appData <- content(tmp)