Hi

I'm trying to connect with a SOLR server, using the POST methods in python, but 
I'm getting an error.

This is the code (full file is attached):

#Form the URL
searchURL  = 'http://localhost:8983/solr/films/query'

querytext = {"json":{"query":"shane"}}
#querytext = {"query":"*:*"}

#form the query
query = urllib.parse.urlencode(querytext).encode('utf-8')

#get data from the server
try:
  connection = urllib.request.Request(searchURL, query)
except Exception as error:
  print("Connection failed: ", error)
  exit()

connection.add_header('Content-Type', 'application/json')

#extract data from the connection made
try:
  response = urllib.request.urlopen(connection)
except Exception as error:
  print("No response returned: ", error)
  exit()

Reponse is:

solr-9.6.1>python python-apps\film-POST.py
No response returned:  HTTP Error 400: Bad Request

Logging on the server gives:

[cid:image001.png@01DB5069.75C84950]
I've attempted many ways resolving this to address the issue, but with no 
success. Can someone help me please?

Cheers
Andy

--------------------------------------------------



Reply via email to