We are trying to find a way to upload an image with AMPScript into Portfolio of the Email Studio (Classic Content) in the Salesforce Marketing Cloud.
I know this is possible with SOAP or REST APIs, but we need it to be done with AMPScript. SOAP API AMPscript Functions can be used though, and this is the only way as far as I understand. But when this code is executed, we get an error:
SET @portfolio = CreateObject('Portfolio') SetObjectProperty(@portfolio, "DisplayName", "API Uploaded2") SetObjectProperty(@portfolio, "CustomerKey", "css-grid-vs-flexbox") SetObjectProperty(@portfolio, "FileName", "css-grid-vs-flexbox.png") SET @resourceSpecification = CreateObject('ResourceSpecification') SetObjectProperty(@resourceSpecification, "URN", "http://cdn.tutorialzine.com/wp-content/uploads/2017/03/css-grid-vs-flexbox.png") SetObjectProperty(@portfolio, "Source", @resourceSpecification) /* Add data */ SET @deStatusCode = InvokeCreate(@portfolio, @deStatusMsg, @deErrorCode) IF @deStatusCode != "OK" THEN RaiseError(@deStatusMsg, 0, @deStatusCode, @deErrorCode) ENDIF
Error Details are below:
Message=Exception occurred during [CreateMedia] ErrorID: 1308368347
Unfortunately, Salesforce support does not provide any support on this, and they do not have any example code in AMPScript.
I found related questions here, but none got an answer, only references to https://developer.salesforce.com which is not helpful in this case: