[SalesForce] Internal Server Error When POST to Marketing Cloud Asset REST API

I am getting an internal server error when trying to save an asset to the content library.

let options = {
  uri: '/asset/v1/content/assets',
  json: true,
  body: MCData
}

const RestClient = new FuelRest({auth: FuelAuthClient});
RestClient.post(options)
.then((result) => {
  console.dir(result);
})
.catch((error) => {
  console.dir(error);
})

The body of my request (MCData) is:

{
  "name":"Document 123",
  "assetType":{
    "name":"png",
    "id":28
  },
  "file":"data:image/png;base64, REST OF THE Encoded IMAGE HERE"
}

I can make a get request to the same endpoint (https://www.exacttargetapis.com/asset/v1/content/assets) and retrieve that I have no content (a correct response with a count of zero).

I am using the FuelSDK-Node-REST library. Error is

{ message: 'Internal Server Error',
 errorcode: 0,
 documentation: 'https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/error-handling.htm' }

Best Answer

So a stupidly simple solution that followed from looking at Timothy's link. I noticed the file in that link had no file type (which MC must be deriving from the Asset Type being created) so I split the Base64 string around the ',' to remove the data:image/png;base64, and retried with success.

Related Topic