Hi,
I am trying to build a Webflow class in Python 3.7.1 to use Webflow API fast and easily in the future but I get an error 404. As it’s my first time using an API, I’ve tried to adapt the Webflow official Javascript client (GitHub - webflow/js-webflow-api: Node.js SDK for the Webflow CMS API) to Python.
Can you help please ?
INPUT:
class Webflow:
def __init__(self,token):
self.end_point='https://api.webflow.com'
self.token=token
self.version=str('1.0.0')
Bearer='Bearer '+token
self.headers={'Accept':'application/json',
'Authorization':Bearer,
'accept-version':self.version,
'Content-type':'application/json'}
def authenticatedFetch(self,method,path,data,query):
queryString='?'+str(query)
uri=self.end_point+path+queryString
opts={'method':method,
'headers':self.headers,
'mode':'cors'}
if type(data)=='dict':
opts['body']=str(data)
response=requests.patch(uri,opts)
return json.loads(response.content.decode('utf-8'))
def GET(self,path,query={}):
return self.authenticatedFetch('GET',path, False, query)
wf=Webflow('my_token')
resultat=wf.GET('/info','')
for i in resultat:
print(i,resultat[i])
OUTPUT:
https://api.webflow.com/info?
msg Route not found: /info
code 404
name RouteNotFoundError
path /info
err RouteNotFoundError: Route not found: /info
meta {'code': 'RouteNotFound'}
errorEnum RouteNotFound
I am not use to post in forums, I hope I’ve been as clear as possible !
Thank you very much!