createRequest method
Implementation
Future<void> createRequest(String name, String description, {String? email}) async {
final userId = await userService.getUserId();
final response = await http.post(
Uri.parse('${apiUrl}requests'),
headers: {
'api-key': apiKey,
'user-id': userId,
"Content-Type": "application/json",
"Accept": "application/json",
},
body: json.encode({
'name': name,
'description': description,
'userId': userId,
'email': email,
'platform': Platform.isAndroid ? 'android' : 'ios',
}),
);
if (response.statusCode == 201) {
return json.decode(response.body);
} else {
throw Exception('Failed to create request');
}
}