0

I am trying to send json data to a database.I am using python and the requests and couchdb libraries. Here is the code :

import requests
import json
import couchdb 
url = 'http://admin:admin@localhost:5984/_utils/#database/products/first_product'
payload = {'first_product':'tshirt','price':"10 dollars'}
res = requests.post(url, data=payload)
print(res.text)

The output tells me that only GET and HEAD method were allowed. But in the documentation, I saw, that it was possible to use POST method. So if we can not use POST we can't make it's own API that use POST method ? Thanks for answering !

  • The code is accessing the [_utils endpoint](https://docs.couchdb.org/en/latest/api/server/common.html#utils), surely it should be the desired [database endpoint](http://127.0.0.1:5984/_utils/docs/api/database/common.html#db). – RamblinRose Aug 03 '22 at 14:19
  • @RamblinRose I succeeded to do a post requests but there is another error that appeared, here is the error; {"error":"bad_request","reason":"invalid UTF-8 JSON"}. If you have any idea, tell me ! Thanks and have a good day/night –  Aug 03 '22 at 17:04
  • https://stackoverflow.com/questions/9733638/how-to-post-json-data-with-python-requests/26344315#26344315 – RamblinRose Aug 03 '22 at 17:35
  • thanks you, I succeeded ! –  Aug 04 '22 at 10:45

0 Answers0