Merge pull request #7333 from edx/clintonb/commerce-json-fix
Corrected data sent to E-Commerce API
This commit is contained in:
@@ -184,7 +184,7 @@ class OrdersViewTests(ModuleStoreTestCase):
|
||||
# Verify the correct information was passed to the E-Commerce API
|
||||
request = httpretty.last_request()
|
||||
sku = CourseMode.objects.filter(course_id=self.course.id, mode_slug='honor', sku__isnull=False)[0].sku
|
||||
self.assertEqual(request.body, 'sku={}'.format(sku))
|
||||
self.assertEqual(request.body, '{{"sku": "{}"}}'.format(sku))
|
||||
self.assertEqual(request.headers['Content-Type'], 'application/json')
|
||||
|
||||
# Verify the JWT is correct
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
""" Commerce views. """
|
||||
|
||||
import json
|
||||
import logging
|
||||
from simplejson import JSONDecodeError
|
||||
|
||||
@@ -111,7 +111,8 @@ class OrdersView(APIView):
|
||||
|
||||
try:
|
||||
timeout = getattr(settings, 'ECOMMERCE_API_TIMEOUT', 5)
|
||||
response = requests.post(url, data={'sku': course_modes[0].sku}, headers=headers, timeout=timeout)
|
||||
response = requests.post(url, data=json.dumps({'sku': course_modes[0].sku}), headers=headers,
|
||||
timeout=timeout)
|
||||
except Exception as ex: # pylint: disable=broad-except
|
||||
log.exception('Call to E-Commerce API failed: %s.', ex.message)
|
||||
return ApiErrorResponse()
|
||||
|
||||
Reference in New Issue
Block a user