hi, I used api 3 to create schedule and it works well. but with api 4.0, when I create a layout with /layout, it has no data in regions, so I cannot get the region playlist, which to attach the medias.
How can I do it correctly with api4.0 ? thanks, below is my former code
// step 2. create layout
const createUrl = ${cms}/api/layout
;
const newLayoutRequest = {
method: ‘post’,
url: createUrl,
headers: {
Authorization: Bearer ${token}
,
‘Content-Type’: ‘multipart/form-data’,
},
data: {
name: layoutName,
resolutionId: resolutionId,
returnDraft: ‘true’,
},
};
const proxyNewLayoutRequest = CommonUtil.checkProxyRequest(newLayoutRequest);
const newResponse = await axios(proxyNewLayoutRequest);
this.logger.info(‘newResponse:’, newResponse);
if (!newResponse.data) {
this.logger.info(‘create Layout error’);
throw new Error(‘create Layout error’);
}
const layoutInfo = newResponse.data;
this.logger.info('layoutInfo:', layoutInfo);
// step3. 为layout赋素材
const {
layoutId, parentId, campaignId, status,
} = layoutInfo;
this.logger.info(`layoutId:${layoutId}parentID:${parentId}status:${status}campaignId:${campaignId}`);
const region = layoutInfo.regions[0];
const { regionId } = region; // **error here because no data in regions**
this.logger.info('regionId:', regionId);
const { playlistId } = region.regionPlaylist;
this.logger.info('playlistId:', playlistId);
const assUrl = `${cms}/api/playlist/library/assign/${playlistId}`;
this.logger.info('assUrl:', assUrl);
const assRequest = {
method: 'post',
url: assUrl,
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'multipart/form-data',
},
data: {
media: _mediaIds,
},
};