var headers = {
'developer-token': 'TOKEN',
'Authorization': 'Bearer ' + ACCESS_TOKEN,
'login-customer-id' : 'MANAGER_ACCOUNT_ID',
'Content-type': 'application/json'
};
var blob = UrlFetchApp.fetch(URL).getBlob();
var bytes = blob.getBytes();
var encodedBlob = Utilities.base64EncodeWebSafe(bytes);
var size = blob.getBytes().length;
var name = FILENAME;
var payload = {
'operations': [
{
"create": {
"name" : name,
"imageAsset": {
"mimeType": 'IMAGE_PNG',
"fullSize": {
"heightPixels": IMAGE_HEIGHT,
"widthPixels": IMAGE_WIDTH,
"url": URL
},
"data": encodedBlob,
"fileSize": size
},
}
},
]
};
var options = {
'headers' : headers,
'method' : 'post',
'contentType': 'application/json',
'payload' : JSON.stringify(payload),
"muteHttpExceptions" : true
};
var response = JSON.parse(UrlFetchApp.fetch(endpoint, options));
The response variable simply contains a Resource Name for the successfully created asset, but when attempting to select/crop the two ratios (1.91:1 and 1:1) and Save, the following error appears in red next to the save button:
There's an error in your selected images. Please remove the image with error before save.