Removing whitespace from request

Hi all,

I am just getting started with postman, and thought it would be a good idea to integrate with the Google Calendar API.

I got the POST part of the request right and it is returning a bearer token as expected. My issue comes in with the second GET request;

It returns 401 authentication error.

I have done some more investigation and believe whitespace to be the issue;

As can be seen from the cURL, it appears that Postman is automatically adds whitespace between the key-value pairs of the request. I have checked my entries and can find no whitespace thereā€¦

So my question is; is there a way to remove this whitespace that is added into my request before sending it?

Hi @robynp31

Looking at your screenshots, I suspect your bearer token is invalid, the header section looks too short.

How are you building your token?

Hi w4dd325,

I obtained my bearer token from the first API call;

Added header values according to an online guidešŸ˜…

My suspicion is that the bearer token is incorrectly read due to the whitespace preceding it?

Does the curl command work if you send it from elsewhere?

for example; Run Curl Commands Online

Unfortunately not. It now returns error code 403
image

{
ā€œerrorā€: {
ā€œcodeā€: 403,
ā€œmessageā€: ā€œRequest had insufficient authentication scopes.ā€,
ā€œerrorsā€: [{
ā€œmessageā€: ā€œInsufficient Permissionā€,
ā€œdomainā€: ā€œglobalā€,
ā€œreasonā€: ā€œinsufficientPermissionsā€
}],
ā€œstatusā€: ā€œPERMISSION_DENIEDā€,
ā€œdetailsā€: [{
ā€œ@typeā€: ā€œtype.googleapis.com/google.rpc.ErrorInfoā€,
ā€œreasonā€: ā€œACCESS_TOKEN_SCOPE_INSUFFICIENTā€,
ā€œdomainā€: ā€œgoogleapis.comā€,
ā€œmetadataā€: {
ā€œmethodā€: ā€œcalendar.v3.Calendars.Getā€,
ā€œserviceā€: ā€œcalendar-json.googleapis.comā€
}
}]
}
}

Found my issue.
The scope for my bearer token was www.googleapis.com/auth/drive
The scope I needed for my GET request is www.googleapis.com/auth/calendar

Both request work without issue now.
Thank you so much for your assistance!:grin:

1 Like

Hmmm ā€¦

I read the docs and Iā€™m not sureā€¦
But here are 2 workspaces that you could fork, they appear to have set up Google Calendar APIā€™s;

Link 1

Link 2

1 Like