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