Error! Failed to publish ecommerce data for courses to LMS

Description
I complete integrate Ecommerce service with LMS service. But when I try to update Demo Courses (EdX default course) or add a new course on https://ecommerce.domain.vn/courses, It raised exception: Error! Failed to publish ecommrce data for {course-v1:course-id} to LMS. You do not have permission to perform this action.

Configuration

  • EdX Version: juniper.2
  • Account login: admin as super account
  • Account worker: ecommerce_worker as super account and filled full information
  • EDX_API_KEY: the same’s on lms.yml and ecommerce.yml
  • JWT_PRIVATE_SIGNING_JWK: the same’s on lms.yml and ecommerce.yml
  • JWT_PUBLIC_SIGNING_JWK_SET: the same’s on lms.yml and ecommerce.yml
  • Discovery service: activated

Log files

  • /edx/var/log/lms/edx.log: nothing
  • /edx/var/log/ecommerce/edx.log:
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][django.request] WARNING [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/django/utils/log.py:228] - Not Found: /api/v2/courses/course-v1:course-id/
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][django.request] WARNING [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/django/utils/log.py:228] - Not Found: /api/v2/courses/course-v1:course-id/
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][django.request] WARNING [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/django/utils/log.py:228] - Not Found: /api/v2/courses/course-v1:course-id/
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][ecommerce.courses.models] INFO [ubuntu  98555] [/edx/app/ecommerce/ecommerce/ecommerce/courses/models.py:195] - Course seat product with certificate type [professional] for [course-v1:course-id] does not exist. Attempted look up using sku [None]. Instantiated a new instance.
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][oscar.alerts] INFO [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/oscar/apps/customer/alerts/utils.py:59] - Sending alerts for 'Enrollment code for professional seat in Course Name ABC'
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][oscar.alerts] INFO [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/oscar/apps/customer/alerts/utils.py:134] - Sent 0 notifications and 0 messages
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][ecommerce.courses.models] INFO [ubuntu  98555] [/edx/app/ecommerce/ecommerce/ecommerce/courses/models.py:244] - Course seat product stock record with certificate type [professional] for [course-v1:course-id] does not exist. Instantiated a new instance.
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][oscar.alerts] INFO [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/oscar/apps/customer/alerts/utils.py:59] - Sending alerts for 'Seat in Course Name ABC with professional certificate'
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][oscar.alerts] INFO [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/oscar/apps/customer/alerts/utils.py:134] - Sent 0 notifications and 0 messages
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][ecommerce.courses.publishers] ERROR [ubuntu  98555] [/edx/app/ecommerce/ecommerce/ecommerce/courses/publishers.py:109] - Failed to publish commerce data for [course-v1:course-id] to LMS. Status was [403]. Body was [{"detail":"You do not have permission to perform this action."}].
Traceback (most recent call last):
  File "/edx/app/ecommerce/ecommerce/ecommerce/courses/publishers.py", line 101, in publish
    commerce_api_client.courses(course_id).put(data=data)
  File "/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/slumber/__init__.py", line 175, in put
    resp = self._request("PUT", data=data, files=files, params=kwargs)
  File "/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/slumber/__init__.py", line 101, in _request
    raise exception_class("Client Error %s: %s" % (resp.status_code, url), response=resp, content=resp.content)
slumber.exceptions.HttpClientError: Client Error 403: https://lms.domain.com/api/commerce/v1/courses/course-v1:course-id/
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][ecommerce.extensions.api.serializers] ERROR [ubuntu  98555] [/edx/app/ecommerce/ecommerce/ecommerce/extensions/api/serializers.py:641] - Failed to save and publish [course-v1:course-id]: [Failed to publish commerce data for course-v1:course-id to LMS. You do not have permission to perform this action.]
Traceback (most recent call last):
  File "/edx/app/ecommerce/ecommerce/ecommerce/extensions/api/serializers.py", line 638, in save
    raise Exception(resp_message)
Exception: Failed to publish commerce data for course-v1:course-id to LMS. You do not have permission to perform this action.
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][django.request] ERROR [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/django/utils/log.py:228] - Internal Server Error: /api/v2/publication/
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][django.request] ERROR [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/django/utils/log.py:228] - Internal Server Error: /api/v2/publication/
Aug 31 20:27:58 ubuntu [service_variant=ecommerce][django.request] ERROR [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/django/utils/log.py:228] - Internal Server Error: /api/v2/publication/
Aug 31 20:31:17 ubuntu [service_variant=ecommerce][django.request] WARNING [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/django/utils/log.py:228] - Unauthorized: /api/v2/courses/course-v1:course-id/
Aug 31 20:31:17 ubuntu [service_variant=ecommerce][django.request] WARNING [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/django/utils/log.py:228] - Unauthorized: /api/v2/courses/course-v1:course-id/
Aug 31 20:31:17 ubuntu [service_variant=ecommerce][django.request] WARNING [ubuntu  98555] [/edx/app/ecommerce/venvs/ecommerce/lib/python3.5/site-packages/django/utils/log.py:228] - Unauthorized: /api/v2/courses/course-v1:course-id/
{ detail: "Not found."}

if I don’t add it on //lms.domain.com/admin/course_modes/coursemode/, and it return detail if I set it

Question

  • I think I wrong configured somewhere. Can you help me this problem?
  • Thank you for your help

I think that it is a permissions problem. The user associated to the ecommerce-backend-client should have permissions to read/edit/write course_modes.

You can add them in /admin/auth/user/<user_id>/change/

In the User permissions section, add all the course_mode | course modes permissions for that user.

image

Not sure if that is the better way to solve that problem, but I worked for me some weeks ago.

3 Likes

It’s very helpful. I spend 2 days more and It’s nothing.
Thank you so much! You saved my life
<3

It’s helpful even in koa.
Thank you. :blush: