addPayloadToProfile method
Future<AddPayloadToProfileResponseDto>
addPayloadToProfile(
- String apiKey, {
- required String profileId,
- required String payloadName,
- required AddPayloadToProfileRequestDto addPayloadToProfileRequestDto,
Implementation
Future<AddPayloadToProfileResponseDto> addPayloadToProfile(
String apiKey, {
required String profileId,
required String payloadName,
required AddPayloadToProfileRequestDto addPayloadToProfileRequestDto,
}) async {
final String url =
'$channel/api/v1/mdm/profiles/$profileId/payloads/$payloadName';
final requestDto = addPayloadToProfileRequestDto.toJson();
requestDto.removeWhere((key, value) => value == null);
final response = await http.post(
Uri.parse(url),
headers: {
'Authorization': 'Zoho-oauthtoken $apiKey',
'Content-Type': 'application/json;charset=UTF-8',
},
body: requestDto.isEmpty ? null : jsonEncode(requestDto),
);
if (!response.statusCode.isSuccessful) {
throw MdmEngineException(
method: response.request?.method,
url: url,
statusCode: response.statusCode,
error: response.body,
);
}
return AddPayloadToProfileResponseDto.fromJson(
jsonDecode(
response.body,
),
);
}