Skip to main content
Best Answer

What is instructors parameter in API


When calling POST /course/v1/courses/{course_id}/sessions

payload as 

{
  "name": "session-2-2",
  "code": "sea2-2",
  "description": "test api session",
  "min_enroll": 0,
  "max_enroll": 20,
  "evaluation_type": 3,
  "instructors": [{

        "id": 13269,
        "firstname": "Jennifer",
        "lastname": "Davis",
        "username": "jennifer.davis"

      }]
}

It returns error: 

{
    "name": "Bad Request",
    "message": [
        "Invalid parameter: instructors"
    ],
    "code": 1002,
    "status": 400
}

Could you let me know what is correct instructors input?

Best answer by Bfarkas

Hmm, nothing is jumping at me, you are positive the 13269 is a valid active user in your instance?

Random question/thought, you are making a new session right, not updating an existing?

View original
Did this post help you find an answer to your question?

7 replies

John
Docebian
Forum|alt.badge.img+2
  • Docebian
  • 125 replies
  • October 6, 2022

Going off the API-Browser’s documentation, the payload should look like this for the endpoint and considering the field parameters you posted:

POST /course/v1/courses/{course_id}/sessions

 

{
  "instructors": [
    13269
  ],
  "name": "session-2-2",
  "code": "sea2-2",
  "description": "test api session",
  "min_enroll": 0,
  "max_enroll": 20,
  "evaluation_type": 3
}

Testing in my trial platform I have received a 200 response (although I swapped out a course ID and user ID for ones that exist in my platform).

From the Course > Session page, I can see the new Session and Instructor assigned:

 


Bfarkas
Hero III
Forum|alt.badge.img+5
  • Hero III
  • 3582 replies
  • October 6, 2022

Yup, above is how I do it, its an array of the docebo id’s of the instructors. The format you have in the above looks more like the GET response than the POST submission.


John
Docebian
Forum|alt.badge.img+2
  • Docebian
  • 125 replies
  • October 6, 2022

@Bfarkas you are right! I posted in part code and in part screen shot. Here’s the full breakdown:

Request URL:

POST https://yourdomain.docebosaas.com/course/v1/courses/93/sessions

Payload:

{
  "instructors": [
    13269
  ],
  "name": "session-3-3",
  "code": "sea3-3",
  "description": "test api session 3",
  "min_enroll": 0,
  "max_enroll": 20,
  "evaluation_type": 3
}

Response:

{"data":{"id_session":36},"version":"1.0.0","_links":[]}

From Chrome console:

 


  • Author
  • Contributor II
  • 16 replies
  • October 6, 2022

I am still getting same error. I have checked the course which is classroom and used same payload 

{
  "instructors": [
    13269
  ],
  "name": "session-3-3",
  "code": "sea3-3",
  "description": "test api session 3",
  "min_enroll": 0,
  "max_enroll": 20,
  "evaluation_type": 3
}

in postman. The different is host url. Any idea?

 


Bfarkas
Hero III
Forum|alt.badge.img+5
  • Hero III
  • 3582 replies
  • Answer
  • October 6, 2022

Hmm, nothing is jumping at me, you are positive the 13269 is a valid active user in your instance?

Random question/thought, you are making a new session right, not updating an existing?


  • Author
  • Contributor II
  • 16 replies
  • October 7, 2022

@Bfarkas , 

Your thought is right. Even that the status shown as “1” in response from /manage/v1/user, it does not work until I go to UI to activate the user manually. 

Thanks both you @John and @Bfarkas to point me right direction.


Bfarkas
Hero III
Forum|alt.badge.img+5
  • Hero III
  • 3582 replies
  • October 7, 2022

cool, glad you got it sorted!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings