Forums

Add to whitelist Tesco api and food2fork

Hello , could you please add: - devportal.tescolabs.com

and:

-http://food2fork.com/about/api.

Thank you very much!

Hi there,

We have whitelisted dev.tescolabs.com and food2fork.com for you as per the documentation.

You guys rock! That was very quick. food2fork works perfectly, unfortunately I still get an error 111 with the Tesco one, I wouldn't be surprised if it's a problem on the way I am doing the connection...should I open another thread or do you think you can give me an heads up on what's happening? Obviously the code is working on local... I am using the httplib module on the one not working, could that be the problem?

That's weird. An http response of 111? Just to confirm, you are trying to access dev.tescolabs.com and not devportal.tescolabs.com right? Maybe tesco is blocking aws ip's etc?

Yeah I am definitely trying to access dev.tescolabs.com and it does work locally. I can show you the code if you want, even If It's pretty ugly at the moment...Is aws Amazon Web Services? I feel like it might just be something dumb I am doing...

EDIT: Actually there is no need to show my code. I literally tried the following, that is the example code shown in the API documentation:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /usr/bin/env python2.7
########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers
    'Ocp-Apim-Subscription-Key': 'CENSORED_PUT_YOUR_API_KEY',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('dev.tescolabs.com')
    conn.request("GET", "/grocery/products/?query=rice&offset=0&limit=10&%s" % params, "", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

Now this piece of code works fine for me locally, while I get an error 111 from pythonanywhere...can you please double check for me that you can make a successful connection with dev.tescolabs.com

oh- could it just be that the api key was wrong? or the documentation isn't updated with the most recent api endpoint / way to submit a query? What happens if you try a different api request? Also maybe try using the requests library and see if that makes any difference? I believe that the httplib/urllib library doesn't obey proxy environment variables (ie. it doesn't realize it needs to go through a proxy). So just use requests.get instead.

Unfortunately I can't really check this particular query because I don't have an api key. But just curl-ing the url works.

Nah, the api key is definitely correct and so is the endpoint. i think I should really try another library...to be honest I should have done that from the beginning so, might aswell... I used urllib2 in the one that it's working so I might try that first, but I agree that requests is the best one. Thank you anyway, I really appreciate the work you guys are doing and I am really happy with the service so far :)

Thanks! Let me second Conrad's suggestion that you give requests a try, in our experience it's the best HTTP library by far, not just in terms of working well with proxies, but also in terms of having a nice, simple, clean programming interface.