Skip to content

Commit

Permalink
Post parameter decode fail
Browse files Browse the repository at this point in the history
  • Loading branch information
PengfeiLi0218 committed Jan 8, 2019
1 parent 81fd586 commit 3955635
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions apitester/runtests/static/runtests/js/runtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ $(function() {
path = $(runner).find('input[name="urlpath"]').val();
testpath = 'run/' + testmethod + "/" + path + "/" + testconfig_pk + "/"+ operationId ;
$.post(testpath, {
'num_runs':$(runner).find('input[name="numRun"]').val(),
'json_body': runner.find('textarea').val(),
'json_body': jsonBody,
'csrfmiddlewaretoken': window.CSRF
}, function (data) {
var alertType = 'success';
Expand Down
8 changes: 5 additions & 3 deletions apitester/runtests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ def get_config(self, testmethod, testpath, testconfig_pk, operation_id):
'urlpath': urlpath if obj is None else obj.urlpath,
'operation_id': operation_id,
'profile_id': testconfig_pk,
'payload': self.request.POST.get('json_body'),
'num_runs': self.request.POST.get('num_runs')
'payload': self.request.POST.get('json_body')
}
try:
testconfig = TestConfiguration.objects.get(
Expand Down Expand Up @@ -295,7 +294,10 @@ def run_test(self, config):
if config['method'] == 'get' or config['method'] == 'delete':
response = self.api.call(config['method'], url)
else:
response = self.api.call(config['method'], url, json.loads(config['payload']))
try:
response = self.api.call(config['method'], url, json.loads(config['payload']))
except:
response = self.api.call(config['method'], url)
try:
text = response.json()
except json.decoder.JSONDecodeError as err:
Expand Down

0 comments on commit 3955635

Please sign in to comment.