Skip to main content
Solved

How do I add an image to sms campaign through via the API?

  • August 23, 2024
  • 7 replies
  • 61 views

Forum|alt.badge.img+2
  • Problem Solver I
  • 10 replies

Is there a way to add an image to an sms campaign through the api? I found a media_url field in the return data for the campaign-messages endpoint but when I try to set a value for that to update or create it doesn’t seem to work. 

 

Best answer by obviyo

I still don’t see a way to add a dynamic image using the api. The attempts above did not work for me. I only ever see null returned for the media_url as mentioned above and that doesn’t seem to correspond to the dynamic image url I set if I try to use the api to pull back an sms campaign I setup in the ux.

 

Thanks!

View original
Did this topic or the replies in the thread help you find an answer to your question?

7 replies

Victoria_ap_G
Expert Problem Solver I
Forum|alt.badge.img+17
  • 2025 Champion
  • 38 replies
  • August 29, 2024

Hi @obviyo 

 

Thanks for your question in the community.

I haven’t added images yet to MMS as its not available in all countries, but this article might be helpful for you. 

 

thanks

Vic


ArpitBanjara
Principal User I
Forum|alt.badge.img+36
  • Principal User I
  • 371 replies
  • August 29, 2024

Hey @obviyo 

The media_url should be a publicly accessible URL. It cannot be a local file path or a URL that requires authentication. Make sure the image is hosted on a server that allows public access.

let me know if this fixes it.

Cheers and thank you for being part of this amazing community

Arpit


Forum|alt.badge.img+2
  • Author
  • Problem Solver I
  • 10 replies
  • August 29, 2024

Hi @ArpitBanjara 

Even if I try to use a publicly available image I still get the same error message: “media_url” is not a valid field for the resource “content” (See screenshot below)

Thanks


ArpitBanjara
Principal User I
Forum|alt.badge.img+36
  • Principal User I
  • 371 replies
  • August 30, 2024

Hey @obviyo 

can you confirm if you have already done the below?

In your uploaded screenshot, the media_url is set to null. Make sure to replace null with the actual URL of your image. 

something like below 

{
  "attributes": {
    "label": "Test SMS API Campaign",
    "channel": "sms",
    "content": {
      "body": "Get this while it lasts!",
      "media_url": "https://example.com/path/to/your-image.jpg"
    }
  }
}

let me know


Forum|alt.badge.img+2
  • Author
  • Problem Solver I
  • 10 replies
  • August 30, 2024

Right, so I’m actually sending in a message through patch request to /api/campaign-messages/{MESSAGE_ID_HERE} that looks very similar to what you have above but it is returning to me with the media_url as null. I’m never setting media_url to null it just always returns as null. See my fuller screenshot below. The above json is what I’m actually sending in. I’ve tried with all kinds of different publicly available image links and it always comes back with the media_url as null.

Thanks again for your help in looking into this.


kaila.lawrence
Community Manager
Forum|alt.badge.img+31
  • Community Manager
  • 499 replies
  • September 6, 2024

@obviyo Have you figured this one out yet or do you still need help?


Forum|alt.badge.img+2
  • Author
  • Problem Solver I
  • 10 replies
  • Answer
  • September 6, 2024

I still don’t see a way to add a dynamic image using the api. The attempts above did not work for me. I only ever see null returned for the media_url as mentioned above and that doesn’t seem to correspond to the dynamic image url I set if I try to use the api to pull back an sms campaign I setup in the ux.

 

Thanks!