pythonruby-on-railshttprequestactiondispatch

ERROR bad Request-Line `m-urlencoded' while posting a GET request from python to rails


I am using request package in python to ping one localhost url on rails. My request header has four extra things which I attached.

s = Session() 
req = Request('GET',  url, data = payload)
prepped = s.prepare_request(req)
prepped.headers['Content-MD5'] = md5
prepped.headers["Authorization"] = auth_header 
prepped.headers['DATE'] = time.strftime("%Y-%m-%d %H:%M")
resp = s.send(prepped)

payload = {'macaddr': '0c:4d:e9:d4:ef:92'}
md5 = 'tgFTRfbbxwZk3VPsUdDXXQ==\n'
auth_header = 'APIAuth 1005:xJGx1wMxFf/j9AdUpd702VIuMag=\n'

And when I am printing these things in controller I am getting only DATE and MD5 not other two things. And this error is also coming bad Request-Line m-urlencoded'


Solution

  • Try changing:

    md5 = 'tgFTRfbbxwZk3VPsUdDXXQ==\n'
    auth_header = 'APIAuth 1005:xJGx1wMxFf/j9AdUpd702VIuMag=\n'
    

    to:

    md5 = 'tgFTRfbbxwZk3VPsUdDXXQ==%0a%0a'
    auth_header = 'APIAuth 1005:xJGx1wMxFf/j9AdUpd702VIuMag=%0a%0a'