Recipe - Food - Nutrition

FREEMIUM
Verified
By David | Updated 4 days ago | Food
Popularity

9.9 / 10

Latency

536ms

Service Level

100%

Health Check

N/A

Back to All Discussions

Visualize Nutrition is not returning any values

Rapid account: Rahulkumar 0630
rahulkumar0630
7 years ago

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
)
);

Rapid account: Spoonacular
spoonacular Commented 7 years ago

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.

Rapid account: Rahulkumar 0630
rahulkumar0630 Commented 7 years ago

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://spoonacularrecipefoodnutritionv1.p.mashape.com/recipes/visualizePriceEstimator",array("XMashapeKey"=>"APIKEY","Accept"=>"text/html","ContentType"=>"application/xwwwformurlencoded"),array("defaultCss"=>true,"ingredientList"=>"3ozflour","mode"=>1,"servings"=>2,"showBacklink"=>true));printr(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" => "3 oz flour", "mode" => 1, "servings" => 2, "showBacklink" => true ) ); print_r(response->raw_body);

?>

Rapid account: Spoonacular
spoonacular Commented 7 years ago

Sorry I cannot reproduce that. Is the sample request on mashape for that endpoint working for you?

Join in the discussion - add comment below:

Login / Signup to post new comments