uploadAPIWithHttpInfo method
This API allows you to upload the image for Visual Search.
Note: This method returns the HTTP Response
.
Parameters:
-
String widgetId (required): The ID of the widget, which can be found in the Widget Configurator in the Dashboard.
-
int accountId (required): Your site's numerical Bloomreach account ID. Your Bloomreach representative gives your site's account ID to you before or during your integration kickoff meeting.
-
String domainKey (required): Your site domain's ID, which Bloomreach provides during initial scoping and integration. This ID is for the domain that you want to receive your Bloomreach API requests. This parameter identifies the specific site version when the one account ID hosts multiple site versions with unique characteristics, such as language versions.
-
MultipartFile
image:
Implementation
Future<Response> uploadAPIWithHttpInfo(String widgetId, int accountId, String domainKey, { MultipartFile? image, }) async {
// ignore: prefer_const_declarations
final path = r'/upload/{widget_id}'
.replaceAll('{widget_id}', widgetId);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
queryParams.addAll(_queryParams('', 'account_id', accountId));
queryParams.addAll(_queryParams('', 'domain_key', domainKey));
const contentTypes = <String>['multipart/form-data'];
bool hasFields = false;
final mp = MultipartRequest('POST', Uri.parse(path));
if (image != null) {
hasFields = true;
mp.fields[r'image'] = image.field;
mp.files.add(image);
}
if (hasFields) {
postBody = mp;
}
return apiClient.invokeAPI(
path,
'POST',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}