Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP request with post-file json data throwing errors #222

Closed
indiranell opened this issue Jul 2, 2018 · 2 comments
Closed

HTTP request with post-file json data throwing errors #222

indiranell opened this issue Jul 2, 2018 · 2 comments

Comments

@indiranell
Copy link

How to make bees attack command for the below scenario:

POST HTTP request with input data(sample.json)

bees attack -n 100 -c 100 -XPOST -u 'http://qainterview.pythonanywhere.com/' -H Accept:/ -P application/json -p sample.json

and sample.json has below input data

{
"number": 20
}
Getting HTTP Error 500 from the server, Is this error related to input data format?

Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "build/bdist.linux-x86_64/egg/beeswithmachineguns/bees.py", line 764, in attack
_sting(param)
File "build/bdist.linux-x86_64/egg/beeswithmachineguns/bees.py", line 383, in _sting
response = urlopen(request)
File "/usr/local/lib/python2.7/dist-packages/future-0.16.0-py2.7.egg/future/backports/urllib/request.py", line 171, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python2.7/dist-packages/future-0.16.0-py2.7.egg/future/backports/urllib/request.py", line 500, in open
response = meth(req, response)
File "/usr/local/lib/python2.7/dist-packages/future-0.16.0-py2.7.egg/future/backports/urllib/request.py", line 612, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python2.7/dist-packages/future-0.16.0-py2.7.egg/future/backports/urllib/request.py", line 538, in error
return self._call_chain(*args)
File "/usr/local/lib/python2.7/dist-packages/future-0.16.0-py2.7.egg/future/backports/urllib/request.py", line 466, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.7/dist-packages/future-0.16.0-py2.7.egg/future/backports/urllib/request.py", line 620, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
HTTPError: HTTP Error 500: Internal Server Error

Can someone please help me in correcting the input data file or share a sample post request with sample input data.

@Spencer-Doak
Copy link

A few things:

  1. Typically, in HTTP, you send the header: "Accept: /", not "Accept:/"
  2. Regardless of the Accept header provided, your request will not work because the site referenced expects application/x-www-form-urlencoded input, not application/json, in which case your sample input should be something like number=20.

All of that said, this is not an issue with the code-base of this application. This is an issue related to improper usage.

@indiranell
Copy link
Author

Thanks for the clarification. Closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants