I am trying to create a template with header media using the Cloud API but my service has been blocked with this message:
Access to XMLHttpRequest at 'https://graph.facebook.com/v19.0/upload:MTphdHRhY2htZW50OjBmMDBmOTNjLWViYTAtNGU2ZC1iNWZmLTM3ZjQwNjIwZjE3YT9maWxlX2xlbmd0aD0xMzg5OTM0MiZmaWxlX3R5cGU9dmlkZW8lMkZtcDQ=?sig=ARZXOtvrVyKDKB_COuc' from origin 'https://im.atimosoftware.com.br' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
By the guides I need send the file to a session previously created, till here every fine, I made made the request and the ID is returned.
When I try to send the file, my request is Blocked by CORS policy.
Here the code used to request upload file:
POST https://graph.facebook.com/{api-version}/{app-id}/uploads
&file_length={file-length}
&file_type={file-type}
&access_token={access-token}
$.ajax({
method: 'POST',
url: `https://graph.facebook.com/v19.0/{app.id}/uploads?file_length=${file.size}&file_type=${file.type}&access_token=${GraphApi.userAccessToken}`
})
.done(function (result) {
if( result.id ){
sendFileToWabaSession(byteArray, result.id)
}
});
POST https://graph.facebook.com/{api-version}/{upload-session-id}
--header 'Authorization: OAuth {access-token}'
--header 'file_offset: 0'
--data-binary @{file-name}
function sendFileToWabaSession( sessionId ){
$.ajax({
url: 'https://graph.facebook.com/v19.0/' + sessionId,
crossDomain: true,
method: 'post',
headers: {
'Authorization': 'OAuth ' + GraphApi.userAccessToken,
'file_offset': '0'
},
data: byteArray
})
.done(function (result) {
if( result.h )
metaHeaderSessionId = result.h;
else{
console.error(result);
}
})
.fail(function () {
console.error(arguments);
});
}
Obs.: byteArray sended is the file selected by user
That is the only endpoint I pass through this error.
Can anyone please help me in this issue?