Hi there
I all the times receiving above error, no matter what image type I use(BMP, PNG, JPEG,JPG)
below is my code that I try to call API
Can you help me please?
<!DOCTYPE html>
<html>
<head>
<script src=“https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js”></script>
</head>
<body>
<input type=“file” id=“input” onchange=“loadFile(event)”>
<script>
function loadFile(event) {
const file = event.target.files[0];
const reader = new FileReader();
reader.onload = (e) => {
const data = new FormData();
data.append(“image”, e.target.result);
data.append(“type”, “pixar”);
const options = {
method: ‘POST’,
url: ‘https://cartoon-yourself.p.rapidapi.com/facebody/api/portrait-animation/portrait-animation’,
headers: {
‘X-RapidAPI-Key’: ‘cce40d4004msh10d9f941cac0181p1e3409jsn8d5fe248c534’,
‘X-RapidAPI-Host’: ‘cartoon-yourself.p.rapidapi.com’
},
data: data
};
axios.request(options)
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.error(error);
});
}
reader.readAsDataURL(file);
}
</script>
</body>
</html>
Participez à la discussion - ajoutez un commentaire ci-dessous:
can I used custom cartoon?
Please Help
@support-vJevsTtR-tQ
Please confirm the data passed in the [image] field, which receives the binary stream data of the image.
and whether the [imageData] field you defined carries the correct data.
You can refer to the official sample code provided by rapidapi.
Getting same issue with Swift.
Can you please help :
class APIHandler{
}
Sorry, the message window of rapidapi was not fully displaying the message, which caused me not to see your code, now I see it, your problem was that you converted the file to base64 to send it, hence the error, you can just use file without converting to base64, the correct code is as follows.
Also note that it is dangerous not to expose your X-RapidAPI-Key here, you can edit your post to change the X-RapidAPI-Key.