Hello, so I am trying to create a meal plan web app where users can generate their meal plan. Using spoonacular’s API. I was able to set up some of the calls I need on Bubble, such as connecting users with spoonacular
However, I have been unsuccessful in trying to set up additional calls because they require a variable path for the user at the endpoint. I keep getting ‘‘you’re not authorised’’ error response when I initialize the call. I’ll be glad if I can get a way around this block
You need to share your API call here if you’d like help debugging it. It sounds like you’re not inserting the username into the API call.
Are you going through the Authentication process?
You have to put an API key in the request URL for every request you make,
for example ?apiKey=YOUR-API-KEY
.
Alternatively, you can put the API key in the request header as x-api-key
.
Well, of course! You are trying to use the username and hash from the example. But you do not have rights for this user.
Read this carefully:
https://spoonacular.com/food-api/docs#Working-with-the-Meal-Planner
Connect user:
https://spoonacular.com/food-api/docs#Connect-User
After connecting, you will receive the necessary data for further work:
{
“status”: “success”,
“username”: “user-1”,
“spoonacularPassword”: “colawithxxxx”,
“hash”: “d8e37a0a0a0558417edc1a9aa80368bXXXXXXXX”
}
Add a Meal-Plan-Template for it:
https://spoonacular.com/food-api/docs#Add-Meal-Plan-Template
And continue down the list from the “Working with the Meal Planner” guide.
.
.
.
.
Oh, I thought it would still run using the example. I created some usernames with the hash as well.
I know I’ll need the username and hash to get meal plan templates but I can’t figure it out. Here’s my attempt
You can only use “x-api-key” and “Content-Type” in the header once, not in every call.
.
.
no need to put “username” in parameters. Use “username” only once in the url (use square brackets instead of curly braces).
Wow! I retried it with the corrections you made and it worked. Thanks so much
Will you be so kind as help me with this Post method as well? Thanks
Amazing! Thank you