I am trying to upload jpg programmatically to Optimizely SaaS CMS. I am running into issues mentioned below.
I am trying via straight up REST API, trying it using postman. But I would be open to other options like using C# Optimizely Graph SDK (if that is an option).
This is what I have tried so far.
I was not able to create image in one step (one POST request), so I broke it down into two requests.
The first is creating a item (an ImageMedia content type item) without the image. Here is the POST request
I am trying to upload jpg programmatically to Optimizely SaaS CMS. I am running into issues mentioned below.
I am trying via straight up REST API, trying it using postman. But I would be open to other options like using C# Optimizely Graph SDK (if that is an option).
This is what I have tried so far.
POST URL: https://api.cms.optimizely.com/preview3/experimental/content
Body JSON:
{
3. The next request is a Patch request, I update the same item id with the actual file, abc.jpg
PATCH Request URL: https://api.cms.optimizely.com/preview3/experimental/content/40531ff4780340e0a9283ce779f2f188
I attach abc.jpg to the file parameter, and set Content-Type to multipart/form-data
Here it the curl request
curl --location --request PATCH 'https://api.cms.optimizely.com/preview3/experimental/content/40531ff4780340e0a9283ce779f2f188' \
--header 'Content-Type: multipart/form-data' \
--header 'Authorization: Bearer <my-bearer-token>
--form 'file=@"/C:/temp/abc.jpg"' \
--form 'Content-Type="multipart/form-data"'
This request fails with a 415 Unsupported media type error.