Help

Welcome to the Airtable Community! If you're new here, check out our Getting Started area to get the most out of your community experience.

Not able to run CircleCI endpoint from Airtable scripting app nor app (custom block)

Topic Labels: Custom extensions
370 0
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi guys,

I was trying to call my CircleCI endpoint from the custom app which contains only one single button with the following request:

 const deploy = async () => {
  const url = 'https://circleci.com/api/v2/project/bitbucket/xyz';
  const token = 'asdasdsa21321423141adasdas';
  const body = {
    branch: 'branchName',
  };

  try {
    const response = await fetch(url, {
      method: 'post',
      body: JSON.stringify(body),
      referrer: 'http://airtable.com',
      headers: {
        'Content-Type': 'application/json',
        Accept: 'application/json',
        'Circle-Token': token,
      },
    });
    const data = await response.json();
    console.log('response data', data);
  } catch (error) {
    console.log('error', error);
  }
};

As a result, I am getting an error:

Access to fetch at ‘https://circleci.com/api/v2/project/bitbucket/xyz’ from origin ‘https://devblock--adasd--vvy7sfo.airtableblocks.com’ 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. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

Then, I added mode: 'no-cors', in the request options and again getting another error:

POST https://circleci.com/api/v2/project/bitbucket/xyz net::ERR_ABORTED 404 (Not Found).

Also, I tried the same thing using a scripting app but facing the same errors.

Any idea about this? Thank you in advance.

0 Replies 0