samuraisam / django-json-rpc

JSON-RPC Implementation for Django
MIT License
286 stars 83 forks source link

Error 400 upgrading 1.5.12 to 1.6.11 #78

Closed boolino closed 8 years ago

boolino commented 8 years ago

I'm working with a big app bassed on django (A) and another smaller one also django based (B). The smaller one (B) feed with data the bigger one (A).

App B stack stayed the same: Django==1.8.4 django-json-rpc==0.7.1

But app A changed from: Django==1.5.12 django-json-rpc==0.6.1

to: Django==1.6.11 django-json-rpc==0.6.1

Now my rpc connection is not working, when I try to send data from B to A it gives me the following error:

In A:

(envA)dev@office-dude platform-a$ ./manage.py runserver 8001
Validating models...

0 errors found
December 04, 2015 - 13:11:57
Django version 1.6.11, using settings 'platform-a.localsettings'
Starting development server at http://127.0.0.1:8001/
Quit the server with CONTROL-C.
[04/Dec/2015 13:15:19] "POST /jsonrpc/ HTTP/1.1" 400 418

In B:

(envB)dev@office-dude platform-b$ ./manage.py shell_plus
......
>> from django.conf import settings
>> from django.core.mail import EmailMessage
>> from django.utils.translation import ugettext as _
>> from jsonrpc.proxy import ServiceProxy
>> import urllib2
>> import json
>> resp_rpc = proxy.accounts.feed_data(data1, data2 ,data3, data4, data5)
JSONRPC: accounts.feed_data error {u'result': None, u'id': None, u'error': {u'executable': u'/home/dev/Envs/platform-a/bin/python', u'code': -32600, u'name': u'InvalidRequestError', u'message': u'InvalidRequestError: Invalid Request.', u'data': None, u'stack': u'Traceback (most recent call last):\n  File "/home/dev/Envs/platform-a/local/lib/python2.7/site-packages/jsonrpc/site.py", line 191, in dispatch\n    raise InvalidRequestError\nInvalidRequestError\n'}}

I've tried debugging my views, models and forms but failed misserably. Can somebody give me a new hint how to fix this issue? It could be a compatibility issue??

Thank you in advance.

samuraisam commented 8 years ago

can you give us a full traceback?

rewritten commented 8 years ago

django-json-rpc 0.6.1 is not compatible with Django 1.6 (as it uses request.raw_post_data instead of request.body). Upgrading to 0.6.3 solved the problem.

samuraisam commented 8 years ago

If someone wanted to write a test for this i'd love to merge it in!

boolino commented 8 years ago

Ok, the version was the real problem , with the new version (0.6.3) everything went back to normal.

Closing issue.

PS: sorry no time for test.

rewritten commented 8 years ago

I'd like to write a test for that, but given it depends on the version (and available methods) of the WSGIRequest class, and you already cover them in TravisCI, I don't think I can cover it more. Using an old version of the library is always poised to fail.