ranesr / fatsecret4j

Java Client for using Fatsecret REST API
0 stars 5 forks source link

Getting an error response #1

Closed unnikrishnan-anil closed 8 years ago

unnikrishnan-anil commented 8 years ago

Running the getFoodItems method is not fetching the results. The response I get is: There was an error in processing your request. Please try again later.

Tried other APIs as well. Facing the same issue.

ranesr commented 8 years ago

I just tried running the code; and it gives me all the results based on the query string.

But, if you are getting the above error message, that means there is some exception. Try adding this line below line 249 in FatSecretAPI.java file - in the catch block,

System.out.println(e.getMessage());

Try getFoodItems method again. You will get more idea about what is going on with the request.

Reply with the message.

unnikrishnan-anil commented 8 years ago

The response to that is null.

ranesr commented 8 years ago

Can you provide me your keys, because I cannot reproduce the problem??

unnikrishnan-anil commented 8 years ago

Consumer - b7395112625b453bb3db8a14a2beb270 Secret - c84fb3562a114b8faacee74b2b5ec9d9

ranesr commented 8 years ago

I just ran the following code-

String key = "b7395112625b453bb3db8a14a2beb270";
String secret = "c84fb3562a114b8faacee74b2b5ec9d9";

FatSecretAPI api = new FatSecretAPI(key, secret);

JSONObject obj = api.getFoodItems("pasta");
System.out.println(obj.toString());

JSONObject obj1 = api.getFoodItemsAtPageNumber("pasta", 4);
System.out.println(obj1.toString());

​=========================================================== And I received the output as -

{"result":{"foods":{"food":[{"food_name":"Penne","food_url":" http://www.fatsecret.com/calories-nutrition/generic/penne-cooked","food_type":"Generic","food_id":"285243","food_description":"Per 101g - Calories: 158kcal | Fat: 0.93g | Carbs: 30.86g | Protein: 5.80g"},{"food_name":"Spaghetti","food_url":" http://www.fatsecret.com/calories-nutrition/generic/spaghetti-cooked","food_type":"Generic","food_id":"4424","food_description":"Per 101g - Calories: 158kcal | Fat: 0.93g | Carbs: 30.86g | Protein: 5.80g"},{"food_name":"Rotini","food_url":" http://www.fatsecret.com/calories-nutrition/generic/rotini-cooked","food_type":"Generic","food_id":"296095","food_description":"Per 101g - Calories: 158kcal | Fat: 0.93g | Carbs: 30.86g | Protein: 5.80g"},{"food_name":"Pasta with Meat Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/generic/pasta-with-meat-sauce","food_type":"Generic","food_id":"5069","food_description":"Per 1274g - Calories: 1643kcal | Fat: 65.23g | Carbs: 166.51g | Protein: 101.03g"},{"food_name":"Meatless Pasta with Tomato Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/generic/pasta-with-tomato-sauce-meatless","food_type":"Generic","food_id":"5068","food_description":"Per 2068g - Calories: 1716kcal | Fat: 9.72g | Carbs: 346.54g | Protein: 63.06g"},{"food_name":"Macaroni","food_url":" http://www.fatsecret.com/calories-nutrition/generic/macaroni-cooked","food_type":"Generic","food_id":"4397","food_description":"Per 101g - Calories: 158kcal | Fat: 0.93g | Carbs: 30.86g | Protein: 5.80g"},{"food_name":"Pasta with Vegetables","food_url":" http://www.fatsecret.com/calories-nutrition/generic/pasta-with-vegetables-no-sauce-or-dressing","food_type":"Generic","food_id":"5073","food_description":"Per 149g - Calories: 186kcal | Fat: 2.21g | Carbs: 34.67g | Protein: 6.72g"},{"food_name":"Fettuccine","food_url":" http://www.fatsecret.com/calories-nutrition/generic/fettuccine","food_type":"Generic","food_id":"292098","food_description":"Per 101g - Calories: 158kcal | Fat: 0.93g | Carbs: 30.86g | Protein: 5.80g"},{"food_name":"Fresh Pasta (Cooked)","food_url":" http://www.fatsecret.com/calories-nutrition/usda/fresh-pasta-(cooked)","food_type":"Generic","food_id":"39764","food_description":"Per 100g - Calories: 131kcal | Fat: 1.05g | Carbs: 24.93g | Protein: 5.15g"},{"food_name":"Angel Hair Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/barilla/angel-hair-pasta","food_type":"Brand","food_id":"60810","food_description":"Per 2 oz - Calories: 200kcal | Fat: 1.00g | Carbs: 42.00g | Protein: 7.00g","brand_name":"Barilla"},{"food_name":"Fettuccine Alfredo","food_url":" http://www.fatsecret.com/calories-nutrition/generic/pasta-fettuccine-alfredo","food_type":"Generic","food_id":"616677","food_description":"Per 373g - Calories: 774kcal | Fat: 32.00g | Carbs: 89.78g | Protein: 30.31g"},{"food_name":"Rigatoni","food_url":" http://www.fatsecret.com/calories-nutrition/generic/rigatoni-cooked","food_type":"Generic","food_id":"406742","food_description":"Per 101g - Calories: 158kcal | Fat: 0.93g | Carbs: 30.86g | Protein: 5.80g"},{"food_name":"Pasta with Cheese and Meat Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/generic/pasta-with-cheese-and-meat-sauce","food_type":"Generic","food_id":"5070","food_description":"Per 835g - Calories: 1244kcal | Fat: 58.62g | Carbs: 108.39g | Protein: 68.14g"},{"food_name":"Bow Tie Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/luigi-vitelli/bow-tie-pasta","food_type":"Brand","food_id":"73038","food_description":"Per 3/4 cup dry - Calories: 210kcal | Fat: 1.00g | Carbs: 44.00g | Protein: 7.00g","brand_name":"Luigi Vitelli"},{"food_name":"Rotini Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/barilla/rotini-pasta","food_type":"Brand","food_id":"61231","food_description":"Per 1 serving - Calories: 200kcal | Fat: 1.00g | Carbs: 42.00g | Protein: 7.00g","brand_name":"Barilla"},{"food_name":"Whole Wheat Spaghetti","food_url":" http://www.fatsecret.com/calories-nutrition/generic/spaghetti-cooked-whole-wheat","food_type":"Generic","food_id":"4428","food_description":"Per 101g - Calories: 124kcal | Fat: 0.54g | Carbs: 26.54g | Protein: 5.33g"},{"food_name":"Linguine","food_url":" http://www.fatsecret.com/calories-nutrition/generic/linguine-cooked","food_type":"Generic","food_id":"298616","food_description":"Per 101g - Calories: 158kcal | Fat: 0.93g | Carbs: 30.86g | Protein: 5.80g"},{"food_name":"Tortellini Pasta with Cheese Filling","food_url":" http://www.fatsecret.com/calories-nutrition/usda/tortellini-pasta-with-cheese-filling","food_type":"Generic","food_id":"40263","food_description":"Per 100g - Calories: 307kcal | Fat: 7.23g | Carbs: 47.00g | Protein: 13.50g"},{"food_name":"Pasta with Carbonara Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/generic/pasta-with-carbonara-sauce","food_type":"Generic","food_id":"5071","food_description":"Per 1786g - Calories: 3410kcal | Fat: 94.81g | Carbs: 459.24g | Protein: 143.74g"},{"food_name":"Whole Grain Penne Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/barilla/whole-grain-penne-pasta","food_type":"Brand","food_id":"53879","food_description":"Per 2 oz - Calories: 180kcal | Fat: 1.50g | Carbs: 39.00g | Protein: 8.00g","brand_name":"Barilla"},{"food_name":"Chicken Alfredo","food_url":" http://www.fatsecret.com/calories-nutrition/fresh-and-easy/chicken-alfredo","food_type":"Brand","food_id":"108301","food_description":"Per 1 cup - Calories: 380kcal | Fat: 13.00g | Carbs: 46.00g | Protein: 19.00g","brand_name":"Fresh & Easy"},{"food_name":"Macaroni (Cooked)","food_url":" http://www.fatsecret.com/calories-nutrition/usda/macaroni-(cooked)","food_type":"Generic","food_id":"39815","food_description":"Per 100g - Calories: 158kcal | Fat: 0.93g | Carbs: 30.86g | Protein: 5.80g"},{"food_name":"Meatless Pasta with Cheese and Tomato Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/generic/pasta-with-cheese-and-tomato-sauce-meatless","food_type":"Generic","food_id":"5072","food_description":"Per 2124g - Calories: 1954kcal | Fat: 29.74g | Carbs: 347.30g | Protein: 78.17g"},{"food_name":"Ziti","food_url":" http://www.fatsecret.com/calories-nutrition/generic/ziti-cooked","food_type":"Generic","food_id":"333937","food_description":"Per 101g - Calories: 158kcal | Fat: 0.93g | Carbs: 30.86g | Protein: 5.80g"},{"food_name":"Flavored Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/generic/flavored-pasta","food_type":"Generic","food_id":"5082","food_description":"Per 636g - Calories: 725kcal | Fat: 28.93g | Carbs: 91.68g | Protein: 23.59g"},{"food_name":"Mostaccioli Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/san-giorgio/mostaccioli-pasta","food_type":"Brand","food_id":"77515","food_description":"Per 2 oz - Calories: 210kcal | Fat: 1.00g | Carbs: 42.00g | Protein: 7.00g","brand_name":"San Giorgio"},{"food_name":"Pasta Shells (Medium)","food_url":" http://www.fatsecret.com/calories-nutrition/wegmans/pasta-shells-(medium)","food_type":"Brand","food_id":"70223","food_description":"Per 3/4 cup dry - Calories: 210kcal | Fat: 1.00g | Carbs: 42.00g | Protein: 7.00g","brand_name":"Wegmans"},{"food_name":"Pasta with Tomato Sauce and Meat or Meatballs (Canned)","food_url":" http://www.fatsecret.com/calories-nutrition/generic/pasta-with-tomato-sauce-and-meat-or-meatballs-canned","food_type":"Generic","food_id":"5013","food_description":"Per 100g - Calories: 103kcal | Fat: 4.08g | Carbs: 12.29g | Protein: 4.32g"},{"food_name":"Cheese Manicotti","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/cheese-manicotti","food_type":"Brand","food_id":"89711","food_description":"Per 1 serving - Calories: 270kcal | Fat: 11.00g | Carbs: 30.00g | Protein: 13.00g","brand_name":"Rosetto"},{"food_name":"Spaghetti (Without Added Salt, Cooked)","food_url":" http://www.fatsecret.com/calories-nutrition/usda/spaghetti-(without-added-salt-cooked)","food_type":"Generic","food_id":"39819","food_description":"Per 100g - Calories: 158kcal | Fat: 0.93g | Carbs: 30.86g | Protein: 5.80g"},{"food_name":"Whole Wheat Fusilli Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/luigi-vitelli/whole-wheat-fusilli-pasta","food_type":"Brand","food_id":"73052","food_description":"Per 2 oz dry - Calories: 210kcal | Fat: 1.50g | Carbs: 41.00g | Protein: 7.00g","brand_name":"Luigi Vitelli"},{"food_name":"Healthy Harvest Whole Wheat Blend Pasta Penne Rigate","food_url":" http://www.fatsecret.com/calories-nutrition/ronzoni/healthy-harvest-whole-wheat-blend-pasta-penne-rigate","food_type":"Brand","food_id":"89216","food_description":"Per 2 oz - Calories: 180kcal | Fat: 1.00g | Carbs: 41.00g | Protein: 7.00g","brand_name":"Ronzoni"},{"food_name":"Chicken & Pasta in Cacciatore Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/nutrisystem/chicken-and-pasta-in-cacciatore-sauce","food_type":"Brand","food_id":"87319","food_description":"Per 1 container - Calories: 130kcal | Fat: 2.00g | Carbs: 18.00g | Protein: 10.00g","brand_name":"NutriSystem"},{"food_name":"Creamy Basil Parmesan Chicken and Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/romanos-macaroni-grill/creamy-basil-parmesan-chicken-and-pasta","food_type":"Brand","food_id":"70522","food_description":"Per 1 cup prepared - Calories: 300kcal | Fat: 11.00g | Carbs: 26.00g | Protein: 26.00g","brand_name":"Romano's Macaroni Grill"},{"food_name":"Fresh Spinach Pasta (Cooked)","food_url":" http://www.fatsecret.com/calories-nutrition/usda/fresh-spinach-pasta-(cooked)","food_type":"Generic","food_id":"39766","food_description":"Per 100g - Calories: 130kcal | Fat: 0.94g | Carbs: 25.04g | Protein: 5.06g"},{"food_name":"Cheese Ravioli","food_url":" http://www.fatsecret.com/calories-nutrition/pede-bros/cheese-ravioli","food_type":"Brand","food_id":"88113","food_description":"Per 9 pieces - Calories: 270kcal | Fat: 6.00g | Carbs: 40.00g | Protein: 12.00g","brand_name":"Pede Bros."},{"food_name":"Whole Wheat Spaghetti (Cooked)","food_url":" http://www.fatsecret.com/calories-nutrition/usda/whole-wheat-spaghetti-(cooked)","food_type":"Generic","food_id":"39791","food_description":"Per 100g - Calories: 124kcal | Fat: 0.54g | Carbs: 26.54g | Protein: 5.33g"},{"food_name":"Spaghetti/Marinara Pasta Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/usda/spaghetti-marinara-pasta-sauce","food_type":"Generic","food_id":"35084","food_description":"Per 100g - Calories: 74kcal | Fat: 2.38g | Carbs: 11.27g | Protein: 1.95g"},{"food_name":"Orzo","food_url":" http://www.fatsecret.com/calories-nutrition/barilla/orzo","food_type":"Brand","food_id":"65509","food_description":"Per 2 oz - Calories: 200kcal | Fat: 1.00g | Carbs: 42.00g | Protein: 7.00g","brand_name":"Barilla"},{"food_name":"Pasta with Pesto Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/generic/pasta-with-pesto-sauce","food_type":"Generic","food_id":"5077","food_description":"Per 526g - Calories: 1656kcal | Fat: 110.58g | Carbs: 123.51g | Protein: 48.58g"},{"food_name":"Italian Sausage & Rigatoni","food_url":" http://www.fatsecret.com/calories-nutrition/bertolli/italian-sausage-and-rigatoni","food_type":"Brand","food_id":"73492","food_description":"Per 1/2 package - Calories: 520kcal | Fat: 27.00g | Carbs: 50.00g | Protein: 19.00g","brand_name":"Bertolli"},{"food_name":"Complete Skillet Meal - Garlic Chicken Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/green-giant/complete-skillet-meal---garlic-chicken-pasta","food_type":"Brand","food_id":"66334","food_description":"Per 1 cup prepared - Calories: 260kcal | Fat: 6.00g | Carbs: 43.00g | Protein: 9.00g","brand_name":"Green Giant"},{"food_name":"Meaty Marinara Baked Tuscani Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/pizza-hut/meaty-marinara-baked-tuscani-pasta","food_type":"Brand","food_id":"50440","food_description":"Per 2.75 cups - Calories: 450kcal | Fat: 21.00g | Carbs: 44.00g | Protein: 2.00g","brand_name":"Pizza Hut"},{"food_name":"Fresh Spinach Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/usda/fresh-spinach-pasta","food_type":"Generic","food_id":"39765","food_description":"Per 100g - Calories: 289kcal | Fat: 2.10g | Carbs: 55.72g | Protein: 11.26g"},{"food_name":"Chicken Penne Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/eating-right/chicken-penne-pasta","food_type":"Brand","food_id":"70920","food_description":"Per 1/2 package - Calories: 270kcal | Fat: 6.00g | Carbs: 36.00g | Protein: 18.00g","brand_name":"Eating Right"},{"food_name":"Mini Bites Mini Pasta Shells & Meatballs","food_url":" http://www.fatsecret.com/calories-nutrition/chef-boyardee/mini-bites-mini-pasta-shells-and-meatballs","food_type":"Brand","food_id":"86071","food_description":"Per 1 cup - Calories: 250kcal | Fat: 10.00g | Carbs: 29.00g | Protein: 8.00g","brand_name":"Chef Boyardee"},{"food_name":"Tortellini Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/racconto/tortellini-pasta","food_type":"Brand","food_id":"50713","food_description":"Per 3/4 cup - Calories: 210kcal | Fat: 1.00g | Carbs: 41.00g | Protein: 7.00g","brand_name":"Racconto"},{"food_name":"Spaghetti (with Added Salt, Enriched, Cooked)","food_url":" http://www.fatsecret.com/calories-nutrition/usda/spaghetti-(with-added-salt-enriched-cooked)","food_type":"Generic","food_id":"39807","food_description":"Per 100g - Calories: 157kcal | Fat: 0.93g | Carbs: 30.59g | Protein: 5.80g"},{"food_name":"Angel Hair Spaghetti Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/meijer/angel-hair-spaghetti-pasta","food_type":"Brand","food_id":"58855","food_description":"Per 1 serving - Calories: 210kcal | Fat: 1.00g | Carbs: 41.00g | Protein: 7.00g","brand_name":"Meijer"},{"food_name":"Dry Spaghetti (Protein Fortified, Enriched, 2)","food_url":" http://www.fatsecret.com/calories-nutrition/usda/dry-spaghetti-(protein-fortified-enriched-2)","food_type":"Generic","food_id":"39838","food_description":"Per 100g - Calories: 374kcal | Fat: 2.23g | Carbs: 65.65g | Protein: 21.78g"}],"page_number":"0","max_results":"50","total_results":"4222"}}}

{"result":{"foods":{"food":[{"food_name":"Whole Wheat Capellini Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/luigi-vitelli/whole-wheat-capellini-pasta","food_type":"Brand","food_id":"73051","food_description":"Per 2 oz dry - Calories: 190kcal | Fat: 0.00g | Carbs: 42.00g | Protein: 9.00g","brand_name":"Luigi Vitelli"},{"food_name":"Pasta Milano","food_url":" http://www.fatsecret.com/calories-nutrition/sbarro/pasta-milano","food_type":"Brand","food_id":"73134","food_description":"Per 1 serving - Calories: 640kcal | Fat: 32.00g | Carbs: 41.00g | Protein: 45.00g","brand_name":"Sbarro"},{"food_name":"Pasta with Beef","food_url":" http://www.fatsecret.com/calories-nutrition/nutrisystem/pasta-with-beef","food_type":"Brand","food_id":"85790","food_description":"Per 1 container - Calories: 170kcal | Fat: 4.50g | Carbs: 21.00g | Protein: 11.00g","brand_name":"NutriSystem"},{"food_name":"Rotini with Meatballs & Tomato Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/nutrisystem/rotini-with-meatballs-and-tomato-sauce","food_type":"Brand","food_id":"86630","food_description":"Per 1 package - Calories: 220kcal | Fat: 6.00g | Carbs: 26.00g | Protein: 17.00g","brand_name":"NutriSystem"},{"food_name":"Chicken, Rigatoni, & Broccoli","food_url":" http://www.fatsecret.com/calories-nutrition/bertolli/chicken-rigatoni-and-broccoli","food_type":"Brand","food_id":"86179","food_description":"Per 1/2 package - Calories: 380kcal | Fat: 16.00g | Carbs: 40.00g | Protein: 22.00g","brand_name":"Bertolli"},{"food_name":"Whole Wheat Spaghetti","food_url":" http://www.fatsecret.com/calories-nutrition/archer-farms/whole-wheat-spaghetti","food_type":"Brand","food_id":"87191","food_description":"Per 2 oz - Calories: 200kcal | Fat: 1.00g | Carbs: 43.00g | Protein: 7.00g","brand_name":"Archer Farms"},{"food_name":"Supper Bakes - Cheesy Chicken with Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/campbells/supper-bakes---cheesy-chicken-with-pasta","food_type":"Brand","food_id":"85847","food_description":"Per 1 cup prepared - Calories: 250kcal | Fat: 5.00g | Carbs: 24.00g | Protein: 24.00g","brand_name":"Campbell's"},{"food_name":"Cheese & Spinach Ravioli with Meat Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/nutrisystem/cheese-and-spinach-ravioli-with-meat-sauce","food_type":"Brand","food_id":"87377","food_description":"Per 1 package - Calories: 240kcal | Fat: 9.00g | Carbs: 28.00g | Protein: 14.00g","brand_name":"NutriSystem"},{"food_name":"Smart Pasta Macaroni","food_url":" http://www.fatsecret.com/calories-nutrition/catelli/smart-pasta-macaroni","food_type":"Brand","food_id":"85364","food_description":"Per 3/4 cup - Calories: 310kcal | Fat: 1.50g | Carbs: 66.00g | Protein: 11.00g","brand_name":"Catelli"},{"food_name":"Organic Whole Wheat Rotelle Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/trader-joes/organic-whole-wheat-rotelle-pasta","food_type":"Brand","food_id":"87701","food_description":"Per 3/4 cup - Calories: 210kcal | Fat: 1.50g | Carbs: 41.00g | Protein: 8.00g","brand_name":"Trader Joe's"},{"food_name":"Oven Bake Meals - Meat Lasagna Rustica","food_url":" http://www.fatsecret.com/calories-nutrition/bertolli/oven-bake-meals---meat-lasagna-rustica","food_type":"Brand","food_id":"87694","food_description":"Per 1/2 package - Calories: 510kcal | Fat: 29.00g | Carbs: 38.00g | Protein: 23.00g","brand_name":"Bertolli"},{"food_name":"Traditional Pasta Fazool Neapolitan Bean Soup","food_url":" http://www.fatsecret.com/calories-nutrition/alessi/traditional-pasta-fazool-neapolitan-bean-soup","food_type":"Brand","food_id":"87859","food_description":"Per 1 cup prepared - Calories: 140kcal | Fat: 0.50g | Carbs: 29.00g | Protein: 6.00g","brand_name":"Alessi"},{"food_name":"Beef Ravioli","food_url":" http://www.fatsecret.com/calories-nutrition/pede-bros/beef-ravioli","food_type":"Brand","food_id":"88111","food_description":"Per 9 pieces - Calories: 310kcal | Fat: 7.00g | Carbs: 44.00g | Protein: 15.00g","brand_name":"Pede Bros."},{"food_name":"Healthy Harvest Whole Wheat Penne Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/ronzoni/healthy-harvest-whole-wheat-penne-pasta","food_type":"Brand","food_id":"88399","food_description":"Per 3/4 cup - Calories: 180kcal | Fat: 1.00g | Carbs: 41.00g | Protein: 7.00g","brand_name":"Ronzoni"},{"food_name":"Macaroni or Noodles with Cheese and Pork or Ham","food_url":" http://www.fatsecret.com/calories-nutrition/generic/macaroni-or-noodles-with-cheese-and-pork-or-ham","food_type":"Generic","food_id":"5064","food_description":"Per 1666g - Calories: 3148kcal | Fat: 149.91g | Carbs: 265.84g | Protein: 175.73g"},{"food_name":"Tomato & Mozzarella Filled Gnocchi","food_url":" http://www.fatsecret.com/calories-nutrition/giovanni-food-company/tomato-and-mozzarella-filled-gnocchi","food_type":"Brand","food_id":"88633","food_description":"Per 1/3 cup - Calories: 190kcal | Fat: 5.00g | Carbs: 31.00g | Protein: 6.00g","brand_name":"Giovanni Food Company"},{"food_name":"Spaghetti with Meat Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/eating-right/spaghetti-with-meat-sauce","food_type":"Brand","food_id":"88864","food_description":"Per 1 tray - Calories: 350kcal | Fat: 9.00g | Carbs: 47.00g | Protein: 17.00g","brand_name":"Eating Right"},{"food_name":"Creamy Deluxe Whole Wheat Shells & Extra Cheesy Chedder Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/annies-homegrown/creamy-deluxe-whole-wheat-shells-and-extra-cheesy-chedder-sauce","food_type":"Brand","food_id":"84804","food_description":"Per 1 cup prepared - Calories: 250kcal | Fat: 4.50g | Carbs: 46.00g | Protein: 11.00g","brand_name":"Annie's Homegrown"},{"food_name":"Gourmet Butternut Squash Ravioli","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/gourmet-butternut-squash-ravioli","food_type":"Brand","food_id":"89719","food_description":"Per 1 serving - Calories: 240kcal | Fat: 3.00g | Carbs: 45.00g | Protein: 8.00g","brand_name":"Rosetto"},{"food_name":"Steam 'n Eat Small Round Cheese Ravioli","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/steam-n-eat-small-round-cheese-ravioli","food_type":"Brand","food_id":"89701","food_description":"Per 1 serving - Calories: 230kcal | Fat: 4.00g | Carbs: 36.00g | Protein: 10.00g","brand_name":"Rosetto"},{"food_name":"Garlic & Herb Chicken Penne","food_url":" http://www.fatsecret.com/calories-nutrition/romanos-macaroni-grill/garlic-and-herb-chicken-penne","food_type":"Brand","food_id":"80326","food_description":"Per 1/3 cup packaged - Calories: 280kcal | Fat: 7.00g | Carbs: 24.00g | Protein: 21.00g","brand_name":"Romano's Macaroni Grill"},{"food_name":"Gourmet Pesto Ravioli with Walnuts","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/gourmet-pesto-ravioli-with-walnuts","food_type":"Brand","food_id":"89718","food_description":"Per 1 serving - Calories: 300kcal | Fat: 8.00g | Carbs: 44.00g | Protein: 12.00g","brand_name":"Rosetto"},{"food_name":"All-Natural Cheese Ravioli","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/all-natural-cheese-ravioli","food_type":"Brand","food_id":"89717","food_description":"Per 1 serving - Calories: 210kcal | Fat: 4.50g | Carbs: 32.00g | Protein: 10.00g","brand_name":"Rosetto"},{"food_name":"Steam 'n Eat Pasta 'n Sauce Cheese Ravioli with Tomato Basil Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/steam-n-eat-pasta-n-sauce-cheese-ravioli-with-tomato-basil-sauce","food_type":"Brand","food_id":"89704","food_description":"Per 1 serving - Calories: 250kcal | Fat: 6.00g | Carbs: 37.00g | Protein: 11.00g","brand_name":"Rosetto"},{"food_name":"Steam 'n Eat Pasta 'n Sauce Cheese Ravioli with Creamy Pink Sauce","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/steam-n-eat-pasta-n-sauce-cheese-ravioli-with-creamy-pink-sauce","food_type":"Brand","food_id":"89703","food_description":"Per 1 serving - Calories: 260kcal | Fat: 7.00g | Carbs: 38.00g | Protein: 11.00g","brand_name":"Rosetto"},{"food_name":"Steam 'n Eat Medium Square Cheese Ravioli","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/steam-n-eat-medium-square-cheese-ravioli","food_type":"Brand","food_id":"89702","food_description":"Per 1 serving - Calories: 230kcal | Fat: 4.00g | Carbs: 37.00g | Protein: 10.00g","brand_name":"Rosetto"},{"food_name":"All-Natural Beef Ravioli","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/all-natural-beef-ravioli","food_type":"Brand","food_id":"89716","food_description":"Per 1 serving - Calories: 220kcal | Fat: 3.50g | Carbs: 39.00g | Protein: 10.00g","brand_name":"Rosetto"},{"food_name":"Cheese & Broccoli Ravioli","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/cheese-and-broccoli-ravioli","food_type":"Brand","food_id":"89713","food_description":"Per 1 serving - Calories: 240kcal | Fat: 5.00g | Carbs: 36.00g | Protein: 11.00g","brand_name":"Rosetto"},{"food_name":"Chicken & Herb Ravioli","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/chicken-and-herb-ravioli","food_type":"Brand","food_id":"89714","food_description":"Per 1 serving - Calories: 170kcal | Fat: 3.00g | Carbs: 26.00g | Protein: 11.00g","brand_name":"Rosetto"},{"food_name":"Penne Alla Vodka","food_url":" http://www.fatsecret.com/calories-nutrition/sbarro/penne-alla-vodka","food_type":"Brand","food_id":"73138","food_description":"Per 1 serving - Calories: 640kcal | Fat: 28.00g | Carbs: 67.00g | Protein: 23.00g","brand_name":"Sbarro"},{"food_name":"Large Round Cheese Ravioli","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/large-round-cheese-ravioli","food_type":"Brand","food_id":"89708","food_description":"Per 1 serving - Calories: 210kcal | Fat: 4.50g | Carbs: 32.00g | Protein: 10.00g","brand_name":"Rosetto"},{"food_name":"Italian Style Ravioli with Sausage","food_url":" http://www.fatsecret.com/calories-nutrition/rosetto/italian-style-ravioli-with-sausage","food_type":"Brand","food_id":"89709","food_description":"Per 1 serving - Calories: 240kcal | Fat: 4.50g | Carbs: 39.00g | Protein: 9.00g","brand_name":"Rosetto"},{"food_name":"Healthy Harvest Whole Wheat Blend Spaghetti Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/ronzoni/healthy-harvest-whole-wheat-blend-spaghetti-pasta","food_type":"Brand","food_id":"89785","food_description":"Per 2 oz - Calories: 180kcal | Fat: 1.50g | Carbs: 39.00g | Protein: 9.00g","brand_name":"Ronzoni"},{"food_name":"Italian Classics Eggplant Lasagna","food_url":" http://www.fatsecret.com/calories-nutrition/wegmans/italian-classics-eggplant-lasagna","food_type":"Brand","food_id":"89918","food_description":"Per 1 cup - Calories: 280kcal | Fat: 17.00g | Carbs: 23.00g | Protein: 10.00g","brand_name":"Wegmans"},{"food_name":"Lobster Ravioli (Cup)","food_url":" http://www.fatsecret.com/calories-nutrition/trader-joes/lobster-ravioli-(cup)","food_type":"Brand","food_id":"89999","food_description":"Per 1 cup - Calories: 260kcal | Fat: 4.00g | Carbs: 42.00g | Protein: 12.00g","brand_name":"Trader Joe's"},{"food_name":"Spaghetti (Without Added Salt, Enriched, Cooked)","food_url":" http://www.fatsecret.com/calories-nutrition/usda/spaghetti-(without-added-salt-enriched-cooked)","food_type":"Generic","food_id":"39787","food_description":"Per 100g - Calories: 158kcal | Fat: 0.93g | Carbs: 30.86g | Protein: 5.80g"},{"food_name":"Steak, Rigatoni & Portobello Mushrooms","food_url":" http://www.fatsecret.com/calories-nutrition/bertolli/steak-rigatoni-and-portobello-mushrooms","food_type":"Brand","food_id":"76055","food_description":"Per 1/2 package - Calories: 380kcal | Fat: 17.00g | Carbs: 38.00g | Protein: 19.00g","brand_name":"Bertolli"},{"food_name":"Rigatoni Romano","food_url":" http://www.fatsecret.com/calories-nutrition/fazolis/rigatoni-romano","food_type":"Brand","food_id":"32687","food_description":"Per 1 package - Calories: 880kcal | Fat: 44.00g | Carbs: 76.00g | Protein: 44.00g","brand_name":"Fazoli's"},{"food_name":"Market Collection Jumbo Rigatoni with Meatballs","food_url":" http://www.fatsecret.com/calories-nutrition/lean-cuisine/market-collection-jumbo-rigatoni-with-meatballs","food_type":"Brand","food_id":"70942","food_description":"Per 1 package - Calories: 420kcal | Fat: 9.00g | Carbs: 62.00g | Protein: 22.00g","brand_name":"Lean Cuisine"},{"food_name":"Whole Wheat Rigatoni","food_url":" http://www.fatsecret.com/calories-nutrition/luigi-vitelli/whole-wheat-rigatoni","food_type":"Brand","food_id":"72939","food_description":"Per 2 oz dry - Calories: 180kcal | Fat: 1.00g | Carbs: 42.00g | Protein: 7.00g","brand_name":"Luigi Vitelli"},{"food_name":"Spinach Stuffed Rigatoni","food_url":" http://www.fatsecret.com/calories-nutrition/mama-cozzi/spinach-stuffed-rigatoni","food_type":"Brand","food_id":"79060","food_description":"Per 1/3 bag - Calories: 410kcal | Fat: 14.00g | Carbs: 53.00g | Protein: 19.00g","brand_name":"Mama Cozzi"},{"food_name":"23 Rigatoni Pasta","food_url":" http://www.fatsecret.com/calories-nutrition/rienzi/23-rigatoni-pasta","food_type":"Brand","food_id":"74120","food_description":"Per 1/8 package - Calories: 200kcal | Fat: 0.50g | Carbs: 43.00g | Protein: 6.00g","brand_name":"Rienzi"},{"food_name":"Lean Gourmet Cheese Stuffed Rigatoni","food_url":" http://www.fatsecret.com/calories-nutrition/michelinas/lean-gourmet-cheese-stuffed-rigatoni","food_type":"Brand","food_id":"74918","food_description":"Per 1 package - Calories: 220kcal | Fat: 6.00g | Carbs: 33.00g | Protein: 8.00g","brand_name":"Michelina's"},{"food_name":"Carmela's Chicken Rigatoni (Lunch)","food_url":" http://www.fatsecret.com/calories-nutrition/romanos-macaroni-grill/carmelas-chicken-rigatoni-(lunch)","food_type":"Brand","food_id":"56396","food_description":"Per 1 serving - Calories: 930kcal | Fat: 54.00g | Carbs: 76.00g | Protein: 36.00g","brand_name":"Romano's Macaroni Grill"},{"food_name":"Carmela's Chicken Rigatoni (Dinner)","food_url":" http://www.fatsecret.com/calories-nutrition/romanos-macaroni-grill/carmelas-chicken-rigatoni-(dinner)","food_type":"Brand","food_id":"56397","food_description":"Per 1 serving - Calories: 930kcal | Fat: 31.00g | Carbs: 111.00g | Protein: 45.00g","brand_name":"Romano's Macaroni Grill"},{"food_name":"Creamy Tomato Rigatoni","food_url":" http://www.fatsecret.com/calories-nutrition/stouffers/creamy-tomato-rigatoni","food_type":"Brand","food_id":"43263","food_description":"Per 1 tray - Calories: 250kcal | Fat: 6.00g | Carbs: 39.00g | Protein: 10.00g","brand_name":"Stouffer's"},{"food_name":"Classic Favorites Creamy Rigatoni with Broccoli & Chicken","food_url":" http://www.fatsecret.com/calories-nutrition/smart-ones/classic-favorites-creamy-rigatoni-with-broccoli-and-chicken","food_type":"Brand","food_id":"44242","food_description":"Per 1 package - Calories: 260kcal | Fat: 4.00g | Carbs: 39.00g | Protein: 16.00g","brand_name":"Smart Ones"},{"food_name":"Gourmet Stuffed Rigatoni with Cheese","food_url":" http://www.fatsecret.com/calories-nutrition/seviroli/gourmet-stuffed-rigatoni-with-cheese","food_type":"Brand","food_id":"53335","food_description":"Per 6 oz - Calories: 370kcal | Fat: 8.00g | Carbs: 60.00g | Protein: 19.00g","brand_name":"Seviroli"},{"food_name":"Culinary Collection Three Cheese Stuffed Rigatoni","food_url":" http://www.fatsecret.com/calories-nutrition/lean-cuisine/culinary-collection-three-cheese-stuffed-rigatoni","food_type":"Brand","food_id":"32595","food_description":"Per 1 package - Calories: 250kcal | Fat: 6.00g | Carbs: 38.00g | Protein: 11.00g","brand_name":"Lean Cuisine"},{"food_name":"Macaroni (Fat Added in Cooking)","food_url":" http://www.fatsecret.com/calories-nutrition/generic/macaroni-cooked-fat-added-in-cooking","food_type":"Generic","food_id":"4399","food_description":"Per 145g - Calories: 262kcal | Fat: 5.84g | Carbs: 43.21g | Protein: 8.12g"}],"page_number":"4","max_results":"50","total_results":"4222"}}}

unnikrishnan-anil commented 8 years ago

Still getting the same error after copy pasting your code. This is so weird!

ranesr commented 8 years ago

Try checking the code line by line, at what line you are getting the object as null.

unnikrishnan-anil commented 8 years ago

I think I found the issue. The code is running the network call on the main thread. Android is not letting me do that. Hence the Network exception. I'll let you know if moving the call to another thread solves the issue, incase you want to make that change.

ranesr commented 8 years ago

Sure, let me know what you find out.

unnikrishnan-anil commented 8 years ago

I created the request using Volley and its working perfectly now.

ranesr commented 8 years ago

What steps did you follow? Maybe, I can add it those to the documentation.

unnikrishnan-anil commented 8 years ago

Here's the snippet of code that I used. You'll need to add Volley to your project ofcourse:

getFoodItems:

`
public void getFoodItems(RequestQueue queue, String query) throws UnsupportedEncodingException { List params = new ArrayList<>(Arrays.asList(generateOauthParams())); String[] template = new String[1]; params.add("method=foods.search"); params.add("max_results=50"); params.add("search_expression=" + encode(query)); params.add("oauth_signature=" + sign(HTTP_METHOD, APP_URL, params.toArray(template)));

    try {
        URL url = new URL(APP_URL + "?" + paramify(params.toArray(template)));
        StringRequest stringRequest = new StringRequest(Request.Method.GET, url.toString(),
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        Log.d("Testing:", "Response: " + response);

                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.d("Testing:", "Testing: " + "Error");
            }
        });
        queue.add(stringRequest);
    } catch (Exception ignored) {

    }
}`

This is only the getFoodItems part. All the network calls might have to be changed to Volley.