When trying to make a request to the Visualize Nutrition Model, I seem to get no information, as if the ingredient was not passed. The widget appears, but everything is at 0%.
This is the example code I used from the website(php):
$response = Unirest\Request::post(“https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/visualizeNutrition”,
array(
“X-Mashape-Key” => “MtxNHYUKjEmshGaXKuFgiuDHA6Fvp1b5IoIjsn9FX5VkHu5JeL”,
“Accept” => “text/html”,
“Content-Type” => “application/x-www-form-urlencoded”
),
array(
“defaultCss” => true,
“ingredientList” => “3 oz flour”,
“servings” => 2,
“showBacklink” => true
)
);
Join in the discussion - add comment below:
Sorry but if the API responds correctly I cannot do much. Unirest is provided by mashape, maybe you can try cURL or ask on stackoverflow regarding your code.
Yes the sample endpoint works for me, which I find strange. I put in the sample code into php and was getting the widget, but everything was at 0%. Also, my Unirest is installed properly because I was using another api on spoonacular which worked.
My PHP Code:
<?php
require_once ‘vendor/autoload.php’;
require_once ‘vendor/mashape/unirest-php/src/Unirest.php’;
// These code snippets use an open-source library. http://unirest.io/php
response=Unirest\Request::post("https://spoonacular−recipe−food−nutrition−v1.p.mashape.com/recipes/visualizePriceEstimator",array("X−Mashape−Key"=>"APIKEY","Accept"=>"text/html","Content−Type"=>"application/x−www−form−urlencoded"),array("defaultCss"=>true,"ingredientList"=>"3ozflour","mode"=>1,"servings"=>2,"showBacklink"=>true));printr(response->raw_body);
?>
Sorry I cannot reproduce that. Is the sample request on mashape for that endpoint working for you?