Update content

To update existing content, you need to first prepare the UpdateContentRequest request payload by importing it.

import 'package:dialogue_wise/DTOs/update_content_request.dart';

Next, you need to prepare the payload by setting the slug, accessToken and source. source can be any text and allows you to identify the source of the content being updated.

var request = new UpdateContentRequest();
request.slug = '[Your Slug]';
request.accessToken = '[Your Access Token]';
request.source = '<Provide a source name>';

Then add the existing fields and their corresponding updated contents.

List<Field> fieldList = [];
var field = new Field();
field.name = '<Provide field name>';
field.value = '<Provide field value>';
fieldList.add(field);
.
.
.
field = new Field();
field.name='[Name of field]';
field.value='[Content for field]';
fieldList.add(field);

Once you have added all the fields and its corresponding content you then set it to the content property. You will need to also set the id property that identifies the content you need to update. You can also set any metadata if you need to, this is completly optional.

var content = new Content();
content.fields = fieldList;
content.id = "<Provide content id>";
request.source = "<Provide a source name>";

content.metadata = new ContentMetadata();
content.metadata!.deviceType = Device.Mobile;
request.content = content;

Now, the payload is ready and you just need to call the updateContent service.

var dialogueWiseService = new DialoguewiseService();
var response = await dialogueWiseService.updateContent(request);

That’s it! You will now get a response which will indicate if your content was added successfully.

For mode details on the implementation, please have a look at the examples available on Github.

Please note, all the contents that are updated will be saved as a draft version. You will need to deploy your Dialogue for it to be available. To understand further, please have a look at Deploying your Dialogue.