How to pass the attendees values using REST API

Sujatha V M
Kilo Patron
Kilo Patron

Hi Team, 

 

Using BR, I'm calling a script include which triggers the REST message and I'm passing request body from the script include, where I'm able to pass the Start and End date & time but unable to pass the attendees list, 

 

var reqbody = {};
            reqbody.summary = "Google Calendar Integration Testing";
            reqbody.start = {};
            reqbody.start.dateTime = isoStartDt; //Variable holding the converted ISO format value
            reqbody.start.timeZone = 'US/Eastern';
            reqbody.end = {};
            reqbody.end.dateTime = isoEndDt; //Variable holding the converted ISO format value
            reqbody.end.timeZone = 'US/Eastern';
            reqbody.attendees = [];
            reqbody.attendees = {};
            reqbody.attendees.email = 'testingoogleinvite@gmail.com';
 
When I ran a Test run, I was able to pass the values as,
 
'attendees': [
{'email': 'testingoogleinvite@gmail.com@gmail.com'},
{'email': 'testing106@gmail.com'}
],
 
How to convert this and pass the values in script?
Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.
1 ACCEPTED SOLUTION

Community Alums
Not applicable

Could you try the below script:

var attendees = [];

var attendeesObj = {}; //For iteration, loop it.
attendeesObj.email = 'testingoogleinvite@gmail.com';
attendees.push(attendeesObj);

gs.print(JSON.stringify(attendees)); 
reqbody.attendees = attendees; // Assigning the final value of the array

Sample Screenshot:

nekkasi_0-1693937403248.png

 

View solution in original post

3 REPLIES 3

Community Alums
Not applicable

Could you try this,

var attendees = [];

var attendeesObj = {}; //For iteration, loop it.
attendeesObj.email = 'testingoogleinvite@gmail.com';
attendees.push(attendeesObj);

gs.print(JSON.stringify(attendees));
reqbody.attendees = JSON.stringify(attendees); // Assigning the final value of the array

Screenshot of the sample output from PDI:

nekkasi_0-1693933840901.png

 

Thank you for the response! I tried the similar way before posting and learnt the mistake! 

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

Community Alums
Not applicable

Could you try the below script:

var attendees = [];

var attendeesObj = {}; //For iteration, loop it.
attendeesObj.email = 'testingoogleinvite@gmail.com';
attendees.push(attendeesObj);

gs.print(JSON.stringify(attendees)); 
reqbody.attendees = attendees; // Assigning the final value of the array

Sample Screenshot:

nekkasi_0-1693937403248.png