I am testing out Edamam's Meal Planning API but am being returned with a 401 error. I have already checked my account application to make sure it is set to the Meal Planning Developer plan so the question of valid id's/key's is ruled out. When testing my id in the documentation's tester it works just fine. This is my code so far:
import express from "express"
import axios from "axios"
import cors from "cors"
import "dotenv/config"
const app = express()
const PORT = process.env.PORT || 5000
app.use(cors())
app.get('/test', async (req, res) => {
try {
const responce = await axios.post(`https://api.edamam.com/api/meal-planner/v1/${process.env.APP_ID}/select`, {
"size": 2,
"plan": {
"accept": {
"all": [
{
"health": [
"VEGAN"
]
},
{
"cuisine": [
"Mediterranean"
]
}
]
}
}
});
res.send(responce.body)
}
catch (ex) {
res.send(ex)
}
})
app.listen(PORT,() => {
console.log(`server is listening to port ${PORT}`)
})
If my app_id and app_key are valid I assume that my code must be wrong. Is there something here I'm not seeing? I also tested the documentation's example in postman and was returned with the same error.
Send POST request to edamam's meal planning API endpoint with simple schema data. Expected meal plan responce from edamam. Was returned with 401 "Missing or invalid credentials."
You missed your account email in header
You can try it from Swagger without any code.