Hi comminity,
I’m trying to use Yotpo’s API documentation to implement Yotpo’s referral into my test shopify store. It’s a pretty basic API implementation, but I’m getting into troubles as the reponse from Yotpo server is always a x-guid and x-api-key headers error.
This is the request I’m sending:
const handleReferral = () => {
fetch(`https://loyalty.yotpo.com/api/v2/referral/share`, {
method: "POST",
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-Guid': 'wuL**************4-XKA',
'X-Api-Key': 'fMRdbg**************rAtt'
},
body: JSON.stringify({
email: 'yotpo_test@yopmail.com',
emails: 'yotpo_test_2@yopmail.com,yotpo_test_3@yopmail.com',
})
})
.then(response => response.json())
.then(resp => {
console.log(`resp: `, resp);
}).catch(e => {
console.error(`Error: `, e);
});
}
so every single time I call to handleReferral() it returns the followin error:
Access to fetch at 'https://loyalty.yotpo.com/api/v2/referral/share' from origin 'https://tsa-test-preview.myshopify.com' has been blocked by CORS policy: Request header field x-guid is not allowed by Access-Control-Allow-Headers in preflight response.
POST https://loyalty.yotpo.com/api/v2/referral/share net::ERR_FAILED
So, as you can see it says always that the x-guid is now allowed by the server so it launches the CORS problem but based on the documentation this is the headers we need to send with the request.
I have to mention the credentials and emails I’m using are ok, but I don’t get this API working.
As a note: if I use Postman for checking the request it will work and still don’t know why.
Following I send some reference images of the error:
![](https://uploads-eu-west-1.insided.com/yotpo-en/attachment/f9c06fe5-e875-4106-8ec1-39e2c04aab92.png)
![](https://uploads-eu-west-1.insided.com/yotpo-en/attachment/bf5cb061-908f-4306-91cc-11d5727d8567.png)
![](https://uploads-eu-west-1.insided.com/yotpo-en/attachment/4281c0ed-dbdd-4a36-ab49-02fcd80b8c5e.png)
Thanks in advance.
Best answer by eschauffer
View original