Upload Image via REST > Cross-origin request? Format for image data (base64 or binary)?
Hi Community,
Some questions from Customer ... appreciate your help.
Thanks!
--Jason
Q1: Cross-Origin Request - what's the meaning?
Here’s our test form:
<form action="http://community.dev04.commsec-it.cba/restapi/vc/users/login/sergey/media/albums/default/public/images/upload" method="post">
<input type="hidden" name="image.content" id="image.content" value="<-- base 64 encoded data goes here -->" />
<input type="submit" value="submit" />
</form>
And we’re getting the following error from the server:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<response status="error">
<error code="307">
<message>
Invalid Cross-Origin Request. Request origin: 'http://demo.dev04.commsec-it.cba' contains no matching allowed origin(s).
</message>
</error>
</response>
I thought commsec-it.cba domain was whitelisted for all operations so I don’t quite understand why we’re getting this error.
Q2: Can you please confirm with your development team in what format should we upload the image data. Is it base64 ? binary ?
Hi JasonL,
Hopefully these will answer your questions:
Q1: Cross-Origion Request errors are sent when you try to make an AJAX request (XMLHttpRequest) from a different domain than either the server domain or one of the domains Lithium has configured your site to allow cross-origin requests from. Please contact support to have additional domains added to the list of allowed domains.
Q2: The upload should be made as an HTTP POST using multipart/form-data encoding -- like this:
<form method="post" enctype="multipart/form-data">
-Doug