Skip to main content
Solved

400 Bad Request in Postman GET


Forum|alt.badge.img+4

I am trying to do a simple GET request using Airtable API in Postman to retrieve my records. But it's not working. I am a newbie here, any help is much appreciated.

GET: https://api.airtable.com/v0/appkEdlvHkUVyG1QC/Sample%201?maxRecords=3

Headers: "Authorization": Bearer Personal_Access_token

Best answer by msafi04

silly mistake from my side

https://api/airtable.com/v0/${baseName}/${tableName}

should be https://api.airtable.com/v0/${baseName}/${tableName}

 

Thank you all for your response

View original
Did this topic help you find an answer to your question?

12 replies

ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8759 replies
  • July 29, 2023

 

You may want to specify either a formula or a view (or both).

This tool will help you create a valid GET request that you can use in Postman:
https://codepen.io/airtable/full/MeXqOg

Alternatively, for a no-code way of retrieving records from Airtable (or interacting with Airtable through its API), you can always use Make’s Airtable integrations.

@SeanKeenan may have more insights.


Forum|alt.badge.img+4
  • Author
  • Inspiring
  • 8 replies
  • July 29, 2023

Thank you @ScottWorld for your response. I tried your suggestion but its not working. 

https://api.airtable.com/v0/appkEdlvHkUVyG1QC/Sample%201?maxRecords=3&view=Grid%20view


ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8759 replies
  • July 29, 2023

Then the problem seems to be with either your authorization or your personal access token.

Your quotation marks look incorrectly placed in your authorization example above, so I would play around with that.

Also, make sure that your personal access token is configured to give you access to what you want.


Forum|alt.badge.img+4
  • Author
  • Inspiring
  • 8 replies
  • July 29, 2023

It's not working either.

I made a simple fetch request in an extension like below and its throwing error too.

const url = "https://api/airtable.com/v0/appkEdlvHkUVyG1QC/Sample%201?view=Grid%20view";
const headers = {
"Authorization":
"Bearer MY_PERSONAL_ACCESS_TOKEN",
"Content-Type": "application/json",
};

const options = {
headers: headers,
method: "GET",
};
const api = await fetch(url, options);
const data = await api.json();
 
Uncaught (in promise) TypeError: Failed to fetch
 
 

ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8759 replies
  • July 29, 2023

Did you check your personal access token settings?

Sorry, I don't know Javascript, so I can't help you there. I would try doing it with Make's Airtable modules because Make doesn't require any coding at all on your end. Then, after Make is successful, you can examine all the code that Make successfully sent to Airtable.

There can be a bit of a learning curve with Make, which is why I created this basic navigation video for Make, along with the links to a few other Make training resources.


Forum|alt.badge.img+4
  • Author
  • Inspiring
  • 8 replies
  • July 29, 2023

Yes I did. I have given read access to my particular base. 


ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8759 replies
  • July 29, 2023

Just in case, make sure that you've got it set for both "data.records:read" and "schema.bases:read".

If that doesn't work, I would try the Make route that I mentioned above.


Forum|alt.badge.img+4
  • Author
  • Inspiring
  • 8 replies
  • August 2, 2023

ScopesWith this token, you will be able to:

  • data.records:read
    See the data in records
  • data.recordComments:read
    See comments in records
  • schema.bases:read
    See the structure of a base, like table names or field types

I have done both.


TheTimeSavingCo
Forum|alt.badge.img+28
msafi04 wrote:

ScopesWith this token, you will be able to:

  • data.records:read
    See the data in records
  • data.recordComments:read
    See comments in records
  • schema.bases:read
    See the structure of a base, like table names or field types

I have done both.


Here, this code works for me within a scripting extension.  Once you've swapped out "YOUR_TOKEN" you should be good to go

Could you provide a screenshot of the relevant table and view as well?

If this doesn't work DM me an invite link to your base and I'll take a look at it for you

 

var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer YOUR_TOKEN"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; await fetch("https://api.airtable.com/v0/appkEdlvHkUVyG1QC/Sample%201?maxRecords=3", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));

 

 

Forum|alt.badge.img+1
  • New Participant
  • 3 replies
  • August 4, 2023

@msafi04 MyEnvoyAir wrote:

I am trying to do a simple GET request using Airtable API in Postman to retrieve my records. But it's not working. I am a newbie here, any help is much appreciated.

GET: https://api.airtable.com/v0/appkEdlvHkUVyG1QC/Sample%201?maxRecords=3

Headers: "Authorization": Bearer Personal_Access_token


Have you checked if your API endpoint and headers are correct? Also, make sure you have a valid personal access token in the "Authorization" header. If you've done all that, please provide more details about the error message or any specific issues you're facing.


Forum|alt.badge.img+4
  • Author
  • Inspiring
  • 8 replies
  • August 7, 2023

Hi, thank you for your response. This is my code 

const airtableURL = `https://api/airtable.com/v0/${baseName}/${tableName}`;

const headers = {
Authorization: "Bearer API_KEY",
"Content-Type": "application/json",
};

const options = {
method: "GET",
headers: headers,
};

const response = await fetch(airtableURL, options);

const tableData = await response.json();
console.log(tableData);
 
This the error
 
Uncaught (in promise) TypeError: Failed to fetch

Forum|alt.badge.img+4
  • Author
  • Inspiring
  • 8 replies
  • Answer
  • August 7, 2023

silly mistake from my side

https://api/airtable.com/v0/${baseName}/${tableName}

should be https://api.airtable.com/v0/${baseName}/${tableName}

 

Thank you all for your response


Reply