Background: I am developing an application based on codeigniter-4 to host my APIs', react native for mobile-application and python3 scripts to upload data to my server (ci4-api) from my desktop.
What is working: I can request/connect to server via POSTMAN app, also I can connect to server from react native app as follows, both shows successful
response = await fetch(url, {method: 'GET'});
what is not working: when I request by using python requests
it throws 406 error, code below
import requests
from requests.exceptions import HTTPError
# url is removed
try:
response = requests.get(url)
response.raise_for_status()
except HTTPError as http_err:
print(f'HTTP error occurred: {http_err}')
except Exception as err:
print(f'Other error occured: {err}')
else:
print('Success')
out >> HTTP error occurred: 406 Client Error: Not Acceptable for url:
In codeigniter I am using get
method in routes. Please let me know your feedback why it fails in python
I have also tried POST method, it is not inserting any data to database in python
payload = { 'id':'sdfr234', 'name' : 'An 23', 'phoneNumber' : '96529', 'password':'qwerty' }
headers = {'Content-Type': 'application/json', 'Accept':'application/json' }
response = requests.post(url, headers = headers, json=payload)