UPC search always returns food_id:0

565 views
Skip to first unread message

George Polak

unread,
Dec 15, 2015, 1:39:36 AM12/15/15
to FatSecret Platform API
Hello,

I have access to the FatSecret Premier API with UPC scanning REST endpoints. However no matter what barcode I use, it always comes back with a food ID of 0. The status code is 200 so I'm not having any authentication problems. This is for barcodes that I can successfully scan with the official FatSecret app.

Example:

Food: Chia Bar Coconut
Barcode: 8 52684 00307 1 (If I type this manually (or scan) in the FatSecret app it resolves correctly)

Request:
http://platform.fatsecret.com/rest/server.api?barcode=852684003071&format=json&method=food.find_id_for_barcode&oauth_consumer_key=<redacted>&oauth_nonce=YSO4ND&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1450158888&oauth_version=1.0&oauth_signature=<redacted>

Response:

{u'food_id': {u'value': u'0'}}



Any help would be appreciated. Thanks!



George Polak

unread,
Dec 21, 2015, 9:00:12 PM12/21/15
to FatSecret Platform API
OK, mystery solved. The barcode has to be zero-padded to EAN-13 format. So 852684003071 in my previous example won't work, but 0852684003071 will.

Sebastian Loch

unread,
Dec 23, 2015, 12:22:14 AM12/23/15
to FatSecret Platform API
Hi George,
Thanks for posting your issue and questions.

We have made a change to the API so that zero-padding is not required anymore.

We appreciate your efforts in developing with the FatSecret Platform API and wish you well.

Kind regards,
Sebastian

Gabriel David

unread,
Oct 12, 2016, 6:01:04 PM10/12/16
to FatSecret Platform API
I can't seem to find the docs for the method food.find_id_for_barcode

Atil Pai

unread,
Oct 22, 2017, 7:14:35 PM10/22/17
to FatSecret Platform API
Hey George, I know this pot is 2 yrs old. But I am a bit stuck here with aauthentication for fatscret. Can you please tell me what is wrong in my procedure to outh signature authenticaation :

These are the steps I take to authenticate, to create the OAuth_signature : 

1)Following step 1 on your API reference page, I created the Signature Base String separately concatenating the percent encoded using (java.net.URLEncoder) ->Request method, url, sorted parameters.

2)Used HMAC SHA-1 algorithm to convert the SBS into the digest octet. (org.apache.commons.lang3.RandomStringUtils)

3)Then I used android library (android.util.Base64) for base64 conversion followed by percent encoding (java.net.URLEncode), to calculate the signature.

I use this to create my final request url, for food.get method.
Get an error code 8, that means invalid signature.

What went wrong in the above steps? Please help.


Thank You !
Reply all
Reply to author
Forward
0 new messages