Hello, I’m new to working with APIs and I’m having difficulty solving this error.
I’m using SQL Server to retrieve data and Python to post it to my collections in webflow
To test out the API process my collections only include two fields: Name and Slug.
This is how I format my resultset from SQL Server (results)
{
"fields": [
{
"slug": "please",
"name": "help",
"_draft": "false",
"_archived": "false"
},
{
"slug": "im-going",
"name": "crazy",
"_draft": "false",
"_archived": "false"
}
]
}
this is my python code
headers={
'Authorization': 'Bearer <######>',
'Accept-Version': '1.0.0',
'Content-Type': 'application/json',
'accept': 'application/json'
}
for myData in results:
data = myData[0]
r = requests.post(
'https://api.webflow.com/collections/5f3ff7d787584bc00a2beb1b/items',
headers=headers,
json=data
)
pprint.pprint(r.json())
and here is the response I get
{'code': 400,
'err': 'ValidationError: Invalid request body',
'msg': 'Invalid request body',
'name': 'ValidationError',
'path': '/collections/5f3ff7d787584bc00a2beb1b/items'}
I feel like I have tried everything and I am wondering if i’m missing something in my JSON. The API documentation is not clear to me (a novice) in terms of what I need to pass to Webflow.
I have tried Zapier with success by connecting it to google sheets but that isn’t a method I want to use. I tried looking up the json behind it but I was unsuccessful. I tried adding the additional columns i saw returned form zapier but i still received the same error message when using python
"updated-on"
"updated-by"
"created-on"
"created-by"
"published-on"
"published-by"
"_cid"
"_id"