Commit 5b2dd87a by Clinton Blackburn

Merge pull request #7333 from edx/clintonb/commerce-json-fix

Corrected data sent to E-Commerce API
parents 63bf1510 acb141a9
......@@ -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
......
""" 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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment