Skip to main content

Can I know what I was missing in the request. I have framed request as for the doceba api explorer documentation but api is failing with 400 error. could you please suggest.

 

api: https://xxxxxxx/learn/v1/courses/402/classroom/session

 

Request: 

{

"name": "ADAS Calibration and Procedures",

"session_code": "7102",

"max_enroll": 40,

"min_enroll": 20,

"last_subscription_date": "2024-02-07",

"other_info": "test",

"evaluation_type": 0,

"score_base": 0,

 

"dates": e

{

"day": "2024-02-26",

"name": "string",

"time_begin": "10:00:00",

"time_end": "12:00:00",

"break_begin": "11:00:00",

"break_end": "11:15:00",

"timezone": "UTC+04:00",

"id_location": 4,

"id_classroom": 4

}

]

}

 

Response:

{

"name": "Bad Request",

"message": a

"p\"Missing required parameter: additional_fields\"]"

],

"code": 0,

"status": 400

}

Using my phone-a-friend to see if @Bfarkas can take a look at this!


So, my first inclination is that this is not the API you actually want to be using. I get that it gets confusing here, but this refers to the old ‘Classrooms’ model which is no longer in use, hence the 400 error.

You are trying to create a session within an ILT course correct?

Try this API instead:

  1. Go to ‘course’ on the services menu in the top left.
  2. Scroll down to the ‘Courses’ category in the left side.
  3. ‘Create a Session in a Course’ is what you are looking for if you want to only make 1 at a time.

Your information above is going to get split between this one, and the Event level one. To make Events, look in the same area but under the ‘Sessions’ category on the left (this gets confusing as you have to think one level above the item you are working on, so Create Session is in course, Create Event is in session.)

Give it a try or let me know what you are trying to do if I misunderstand.


Heres the Create Session one in the browser:

 

Heres the Create Event:
 

 


Thank you @Bfarkas this helps a lot.


No problem, let me know how you make out down that path.


This post might actually come in handy for you as you get acquainted with the browser, it can be confusing as some things have changed over time or go by different names:

 


@Bfarkas as for your suggestion I was trying to create session for the existing course. I am still getting 400 error. could you give me one sample json for creating session.

 

Request I was using:

{

"instructors": :

{"id": 53417,

"firstname": "Guy",

"lastname": "Vesco",

"username": "VescoGuy"}

],

"additional_fields": :

{

"id": "12",

"title": "ProgamType",

"type": "dropdown",

"visible_to_user": "1",

"settings": " ]",

"mandatory": true,

"value": "Autotech"

},

{

"id": "8",

"title": "ClassSponsor",

"type": "textfield",

"visible_to_user": "1",

"settings": " ]",

"mandatory": true,

"value": "Chicago DC"

},

{

"id": "6",

"title": "AssociatedDC",

"type": "dropdown",

"visible_to_user": "1",

"settings": " ]",

"mandatory": false,

"value": "ATLANTA"

},

{

"id": "7",

"title": "Market",

"type": "dropdown",

"visible_to_user": "1",

"settings": " ]",

"mandatory": false,

"value": "Market1"

},

{

"id": "9",

"title": "OfferingZipCode",

"type": "textfield",

"visible_to_user": "1",

"settings": " ]",

"mandatory": false,

"value": "60440"

},

{

"id": "14",

"title": "ContactName",

"type": "textfield",

"visible_to_user": "1",

"settings": " ]",

"mandatory": false,

"value": "Contact Name1"

},

{

"id": "16",

"title": "ContactPhone",

"type": "textfield",

"visible_to_user": "1",

"settings": " ]",

"mandatory": false,

"value": "630-555-1212"

},

{

"id": "17",

"title": "ContactEmail",

"type": "textfield",

"visible_to_user": "1",

"settings": " ]",

"mandatory": false,

"value": "contactname@mail.com"

},

{

"id": "15",

"title": "Meeting Invitation",

"type": "textarea",

"visible_to_user": "1",

"settings": " ]",

"mandatory": false,

"value": null

},

{

"id": "10",

"title": "SendBooksTo",

"type": "textfield",

"visible_to_user": "0",

"settings": " ]",

"mandatory": false,

"value": null

},

{

"id": "11",

"title": "Income",

"type": "textfield",

"visible_to_user": "0",

"settings": " ]",

"mandatory": false,

"value": null

},

{

"id": "13",

"title": "Notes",

"type": "textarea",

"visible_to_user": "0",

"settings": " ]",

"mandatory": false,

"value": null

}

],

"name": "ADAS Calibration and Procedures - Atlanta DC",

"code": "",

"description": "Class for Atlanta, IL Market",

"min_enroll": 0,

"max_enroll": 60,

"score_base": 0,

"custom_deadline_days": 2,

"evaluation_type": "3",

"min_attended_dates_for_completion": 0,

"custom_rsvp_enabled": true

}

 

 


Based on the error message and looking at it, your instructors are misformated, they should be more like this:

"instructors": [
53417
],

 


@Bfarkas  instructor error was gone and getting addition field error

 

 


Please read the errors, it is telling you what is wrong. In this case you have addiitonal field 12 marked as mandatory when it is not, change it to false:

 

but, more so, you have the wrong format and set up for all the additional fields here, it seems like you are using the format used when creating an additional field. If you look at the schema defined in the API browser for this call, you just need the field ID and value you want to select:

 

So your additional field set should look more like:

 "additional_fields": :
{
"id": 12,
"value": "Autotech"
},
{
"id":8,
"value": "Chicago DC"
}
],

 

You may need to lookup the values of the additional field instead of using the text, depending on the field type. You can find this in the ‘learn’ service of the API, select the ‘Course’ category, and then there are a couple of additional field calls such as ‘Retrieves the list of all course additional fields, optionally filtered with the input parameters.’ which will list the fields and their choice values.


Make sure you are reading the ‘Body Sample’ and ‘Body Schema’ for each API you are using, it seems like you are copying formats from different endpoints to use here which are not correct. Each endpoint often needs a different set of information, it is what is so great about the API browser is this is detailed for each endpoint.


@Bfarkas  appreciate all your help.  Thank you very much I was trying to get acquainted to the domain. I verified additional fields api it looks I am giving the right value or not sure  but still session creation is throwing 400 error
 

 

 


So for dropdowns, the ‘Value’ is the option number, so based on the second screenshot above it should be 154, not Autotech.


it can be useful to basically keep a lookup table or key of the additional field values if you are going to do a lot of these.


@Bfarkas two issues now says invalid parameter enrollment deadline

if I remove enrollment deadline then I am getting invalid evaluation type
 

 


So according to the Body Schema of this API Endpoint, you cannot have both the enrollment deadline and the custom deadline days together:

 

This is common for the optional parameters. All the optional will be shown in the ‘Body Sample’ box, but you need to only keep the ones you actually need. Make sure to read through the Body Schema of the endpoint in the API browser.


@Bfarkas  Got you. any idea why its not acception any  of 0,1,2,3 for evalution type as for specified in schema documentation


Without seeing the full call, my guess is that you have optional parameters that do not apply to it. Each type has different optional settings that correspond to it and if you have a mix, it will seem like that value is incorrect. 

manual cant have score based settings for example.

attendance based uses the minimal attended dates, otherwise not needed for a second example.

Only keep the parameter settings that are needed.


@Bfarkas  here is the complete request

{

"instructors":

53417

],

"additional_fields":

{

"id": 12,

"value": "154"

},

{

"id": 8,

"value": "ClassSponsor"

},

{

"id": "13",

"value": "Notes"

},

{

"id": "17",

"value": "ContactEmail"

},

{

"id": "15",

"value": "Meeting Invitation"

}

],

"name": "ADAS Calibration and Procedures - Atlanta DC",

"code": "",

"description": "Class for Atlanta, IL Market",

"min_enroll": 0,

"max_enroll": 60,

"score_base": 0,

"enrollment_deadline": "2024-02-28",

"evaluation_type": 3,

"min_attended_dates_for_completion": 1,

"custom_rsvp_enabled": true

}

 

 


Right, so you are trying to do 3, which is manual, but then have parameters set for:

"min_attended_dates_for_completion": 1,

"score_base": 0,

 

those are for other types, not manual.


I just tried this from yours without the additional fields since I do not have those, and it worked as expected:

{
"name": "ADAS Calibration and Procedures - Atlanta DC",
"code": "",
"description": "Class for Atlanta, IL Market",
"min_enroll": 0,
"max_enroll": 60,
"enrollment_deadline": "2024-02-28",
"evaluation_type": 3,
"custom_rsvp_enabled": true
}

you need to match the evaluation type with the parameters you are adding in the call. If you are not really sure what pairs, it is sometimes useful to go use the systems front end UI as if you pick the type you only get the right options so you can learn the differences.


@Bfarkas

Appreciate your patience in responding to my messages but  I tried to create session for couple of already existing ILT courses I was getting the same error for all of them saying "Invalid parameter for the evaluation type" I tried to use all the options 0,1,2,3 nothing worked. As u said above I tried with payload with out instructor and additional fields saying “required additional fields”
 

  Then I tried again keeping instructor and additional fields now I am getting "Invalid parameter for the evaluation type" I tried with all the options of evaluation type 0,1,2,3 none worked
 

tried to check any existing sessions for ILT course  from UI for all ILT courses I am seeing no sessions avaialble
 

 

none of the ILT courses have scheduled sessions. looks strange. I was trying to create sessions from postman these were also failing. Not sure what I am doing wrong. Here is my payload for creating ILT course session

 

url: https://gpcsandbox.docebosaas.com/course/v1/courses/467/sessions

request payload:

{

"instructors": >

53417

],

"additional_fields": t

{

"id": "8",

"value": "ClassSponsor"

},

{

"id": 12,

"value": "154"

}

],

"name": "Brake Service and Repair (Hands-on) - Atlanta DC",

"code": "",

"description": "Class for Brake Service and Repair, IL Market",

"min_enroll": 0,

"max_enroll": 60,

"score_base": 0,

"enrollment_deadline": "2024-02-28",

"evaluation_type": 3,

"min_attended_dates_for_completion": 1,

"custom_rsvp_enabled": true

}


Hi - Yeah, so you seem to be mixing up a bunch of the threads here. I did not say to remove the instructors/additional fields, just that I had to as I do not have your additional fields so i could not use to test. The more important thing is that depending on which evaluation type you choose, so in your case 3 - manual, you cannot include certain other options/parameters. For manual you cannot have a score_base or a min_attended_dates_for_completion, as those are for the other types. You need to adjust these parameters based on the evaluation type you set.

So adjusting the body you posted above, this should look like the following:

{
"instructors": [
53417
],
"additional_fields": [
{
"id": "8",
"value": "ClassSponsor"
},
{
"id": 12,
"value": "154"
}
],
"name": "Brake Service and Repair (Hands-on) - Atlanta DC",
"code": "",
"description": "Class for Brake Service and Repair, IL Market",
"min_enroll": 0,
"max_enroll": 60,
"enrollment_deadline": "2024-02-28",
"evaluation_type": 3,
"custom_rsvp_enabled": true
}

You need to understand the different evaluation types and what settings correspond to them, that is why I recommended going into the UI, as you can click through the types and seeing which choices correspond.


@Bfarkas  Thanks appreciate all your help finally I was able to create session….


Reply