HTTP/1.1 403 Forbidden
Team,
I am using the Sample code provided with the SDK and it works on my desktop (Windows 10 - JDK 1.8.x). The same code deployed on my Linux server - JDK 1.8 fails with the following error
What is the cause of this error when it works fine on my desktop?
{
request:{
command:'GET https://api.smartsheet.com/2.0/sheets',
},
response:{
status:'HTTP/1.1 403 Forbidden',
body:'**contentType 'text/html; charset=utf-8' not logged**'
}
}
com.smartsheet.api.SmartsheetException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
Its clear that I am receiving a HTML instead of a JSON.
I have also enabled
// Uncomment these lines to enable logging to console
System.setProperty("Smartsheet.trace.parts", "RequestBody,ResponseBodySummary");
System.setProperty("Smartsheet.trace.pretty", "true");
Thank you
Prashanth
Comments
-
A request will return a 403 Forbidden status code when the Authentication fails. The response body for your request might look similar to this if you logged it:
{
"errorCode": 1004,
"message": "You are not authorized to perform this action.",
"refId": "61yc3htatye3"
}Have you looked at the Authorization Header on your request to verify it has an Access Token being passed? How have you configured the client for making this request?
-
Dave,
Thank you for a quick response. I am using the Sample code provided in the SDK and it works fine on my local but fails from our development environment. So it must be something else.
Is there any other debugging i can enable to see whats going out?
Thank you
Prashanth
-
Prashanth,
There is more information on logging with the Java SDK in the Advanced topics section on Github here:
https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/master/ADVANCED.md#logging
That should help you to see what is being sent to the Smartsheet API and what is being received back to your application.
Have you confirmed you can reach the Smartsheet API from your development environment? Could there be a proxy issue?
Info on that is in the Advanced topics as well here:
-
Let me check. I will get back in case i have any questions.
-
Dave,
Below is the request and the response. The Authorization header has the Access token being sent. Not sure why SmartSheet is refusing access.
{
request:{
command:'GET https://api.smartsheet.com/2.0/sheets',
headers:{
'Authorization':'Bearer ****p7hx',
'Content-Type':'application/json',
'User-Agent':'Smartsheet Java SDK/2.2.9/smartsheet-sdk-java-2.2.9.jar!com.smartsheet.api.SmartsheetBuilder/Linux Java HotSpot(TM) 64-Bit Server VM Oracle Corporation 1.8.0_51',
},
},
response:{
status:'HTTP/1.1 403 Forbidden',
headers:{
'Cache-Control':'no-cache',
'Connection':'Keep-Alive',
'Content-Length':'671',
'Content-Type':'text/html; charset=utf-8',
'Pragma':'no-cache',
'Proxy-Connection':'Keep-Alive',
},
body:'**contentType 'text/html; charset=utf-8' not logged**'
}
}Thank you
Prashanth
-
Dave,
Our proxy was blocking the traffic. I will let you know if it got fixed at our end. Thank you for your assistance.
Prashanth
-
Glad to hear. Sounds like you are making progress!
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 63.7K Get Help
- 405 Global Discussions
- 216 Industry Talk
- 456 Announcements
- 4.7K Ideas & Feature Requests
- 141 Brandfolder
- 136 Just for fun
- 57 Community Job Board
- 459 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 297 Events
- 37 Webinars
- 7.3K Forum Archives