Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-40410

Creating a Gradebook Item via the rest api returns a 400 even though the gbItem gets created

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: OPEN
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 12.2, 12.3
    • Fix Version/s: None
    • Component/s: Gradebook
    • Labels:
    • Test Plan:
      Hide

      Make a post request to the gradebook item endpoint. 

       

      title = "Assignment 17" // This title needs to be changed each time otherwise you'll just be updating.
      siteId = "309f618a-fa82-47c8-96e5-d2e428f70182"
      json = {
      {{ "dueDate": 1522357200000,}}
      {{ "name": title,}}
      {{ "pointsPossible": 39,}}
      {{ "scores": [],}}
      {{ "externalID": title,}}

      }
      $.ajax({
      {{ url: "/direct/grades/gradeitem/" + siteId + ".json",}}
      {{ data: JSON.stringify(json), }}
      {{ type: 'POST',}}
      {{ contentType: "text/json",}}
      {{ success : function() { debugger},}}
      {{ error : function (xhr, ajaxOptions, thrownError){ }}
      {{ console.log(xhr.status); }}
      {{ console.log(xhr.responseText); }}
      {{ console.log(thrownError);}}
      {{ } }}
      });

       

      You should get a 400 the first time. Resend it, and you'll get a 200 b/c it's just updating the newly created gradebook item the second time.

      Show
      Make a post request to the gradebook item endpoint.    title = "Assignment 17" // This title needs to be changed each time otherwise you'll just be updating. siteId = "309f618a-fa82-47c8-96e5-d2e428f70182" json = { {{ "dueDate": 1522357200000,}} {{ "name": title,}} {{ "pointsPossible": 39,}} {{ "scores": [],}} {{ "externalID": title,}} } $.ajax({ {{ url: "/direct/grades/gradeitem/" + siteId + ".json",}} {{ data: JSON.stringify(json), }} {{ type: 'POST',}} {{ contentType: "text/json",}} {{ success : function() { debugger},}} {{ error : function (xhr, ajaxOptions, thrownError){ }} {{ console.log(xhr.status); }} {{ console.log(xhr.responseText); }} {{ console.log(thrownError);}} {{ } }} });   You should get a 400 the first time. Resend it, and you'll get a 200 b/c it's just updating the newly created gradebook item the second time.

      Description

      Making a post request to create a gradebook item returns a status code of 400, but the gradebook item actually gets created.

       

      Seems like `gbItem.id` never gets set, so when it enters `org.sakaiproject.component.gradebook.GradebookServiceHibernateImpl.getAssignment`, `assignmentId` is null and an `IllegalArgumentException` is thrown. (https://github.com/sakaiproject/sakai/blob/master/edu-services/gradebook-service/impl/src/java/org/sakaiproject/component/gradebook/GradebookServiceHibernateImpl.java#L175)

       

      ```
      02-Aug-2018 15:08:26.501 ERROR [http-nio-20002-exec-37] org.sakaiproject.profile2.logic.SakaiProxyImpl.getResource SakaiProxy.getResource() failed for resourceId: /private/profileImages/b7d333a6-6f22-4422-8b1f-b2bc60cc8136/1/3572752c-7062-4886-95c3-0d83c334b08d : class org.sakaiproject.exception.ServerOverloadException : Failed to read resource body
      02-Aug-2018 15:09:11.797 INFO [pool-2-thread-1] org.sakaiproject.authz.impl.DbAuthzGroupService.run RefreshAuthzGroupTask.run() refreshed 2 realms in 0.148 seconds, longest realm was /site/a150b178-dec8-4df3-a2a6-6b57eec8b1be at 0.145 seconds
      02-Aug-2018 15:23:03.032 INFO [http-nio-20002-exec-36] org.sakaiproject.component.gradebook.GradebookExternalAssessmentServiceImpl.addExternalAssessment External assessment added to gradebookUid=a150b178-dec8-4df3-a2a6-6b57eec8b1be, externalId=Assignment 19 by userUid=b7d333a6-6f22-4422-8b1f-b2bc60cc8136 from externalApp=GB_REST
      02-Aug-2018 15:23:03.039 WARN [http-nio-20002-exec-36] org.sakaiproject.gradebook.logic.ExternalLogic.saveGradebookItem Invalid assignment (gb=a150b178-dec8-4df3-a2a6-6b57eec8b1be, item={Assignment 19 [null, Assignment 19] 39.0:Thu Mar 29 17:00:00 EDT 2018:internal::[]}, asgn=null): cannot create: java.lang.IllegalArgumentException: null parameter passed to getAssignment. Values are assignmentId:null gradebookUid:a150b178-dec8-4df3-a2a6-6b57eec8b1be
      java.lang.IllegalArgumentException: null parameter passed to getAssignment. Values are assignmentId:null gradebookUid:a150b178-dec8-4df3-a2a6-6b57eec8b1be
      at org.sakaiproject.component.gradebook.GradebookServiceHibernateImpl.getAssignment(GradebookServiceHibernateImpl.java:174)
      at sun.reflect.GeneratedMethodAccessor2617.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
      at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
      at com.sun.proxy.$Proxy88.getAssignment(Unknown Source)
      at org.sakaiproject.gradebook.logic.ExternalLogic.saveGradebookItem(ExternalLogic.java:681)
      at org.sakaiproject.gradebook.entity.GradesEntityProvider.handleGradeItem(GradesEntityProvider.java:193)
      at sun.reflect.GeneratedMethodAccessor2105.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.sakaiproject.entitybroker.rest.EntityActionsManager.handleCustomActionExecution(EntityActionsManager.java:206)
      at org.sakaiproject.entitybroker.rest.EntityActionsManager.handleCustomActionRequest(EntityActionsManager.java:96)
      at org.sakaiproject.entitybroker.rest.EntityHandlerImpl.handleEntityAccess(EntityHandlerImpl.java:409)
      at org.sakaiproject.entitybroker.util.servlet.DirectServlet.dispatch(DirectServlet.java:189)
      at org.sakaiproject.entitybroker.servlet.SakaiDirectServlet.dispatch(SakaiDirectServlet.java:148)
      at org.sakaiproject.entitybroker.util.servlet.DirectServlet.handleRequest(DirectServlet.java:159)
      at org.sakaiproject.entitybroker.util.servlet.DirectServlet.service(DirectServlet.java:134)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.sakaiproject.oauth.filter.OAuthPostFilter.doFilter(OAuthPostFilter.java:76)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.sakaiproject.util.RequestFilter.doFilter(RequestFilter.java:467)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.sakaiproject.oauth.filter.OAuthPreFilter.doFilter(OAuthPreFilter.java:74)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
      at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:685)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471)
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:748)
      ```

        Gliffy Diagrams

          Zeplin

            Attachments

              Activity

                People

                Assignee:
                Unassigned Unassigned
                Reporter:
                karenling Karen Ling
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:

                    Git Integration