Using merge field on an image asset with the src defined as a mergefield error

Currently using the python sdk to render templates and I am using a merge field to suplement an imageasset’s src (publicly hosted s3 image) but I am getting this error.

HTTP response body: {"success":true,"message":"Bad Request","response":{"error":{"name":"ValidationError","details":[{"message":"\"src\" must be a string","path":["timeline","tracks",8,"clips",0,"asset","src"],"type":"string.base","context":{"value":null,"key":"src","label":"src"}}]}}}

Not sure why this is the case

This would indicate to me that the merge did not happen correctly, the src has no no value and validation expects it to be a string, but instead the value is null.

Without seeing the code it is hard to know exactly but there is an example here to create and render a template using Python:

In your code if you add the following line after you have prepared the merge fields and the template ready to post to the API then you can inspect the JSON generated by the SDK before posting it like this:

template = TemplateRender(
  id = id,
  merge = [
    merge_field_url,
    merge_field_trim,
    merge_field_length
  ]
)

print(template.to_str())

sys.exit()

You should then be able to see what the JSON looks like and work backwards to see why the merge field for the src has not been set.