Best Answer

What is instructors parameter in API

  • 6 October 2022
  • 7 replies
  • 69 views

Userlevel 2

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?

icon

Best answer by Bfarkas 7 October 2022, 00:17

View original

7 replies

Userlevel 5
Badge +2

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:

 

Userlevel 7
Badge +3

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.

Userlevel 5
Badge +2

@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:

 

Userlevel 2

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?

 

Userlevel 7
Badge +3

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?

Userlevel 2

@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.

Userlevel 7
Badge +3

cool, glad you got it sorted!

Reply