403 Error Uploading with REST API

  • 1
  • Problem
  • Updated 5 months ago
I'm trying to upload files from ServiceNow to ShareFile. I have a folder which I have access to when I log in directly to ShareFile and I am able to add files to the folder. When I make API calls I have valid access token and have been able to retrieve a ChunkUri. I then make a POST call to the ChunkUri with the file attached to the request body. I keep getting a 403 error with code 6 - Forbidden username/password combo and a response of "You do not have permission to view this directory or page." I'm not sure what I'm doing wrong as I know I have access to the folder and the ability to upload files manually.
Photo of Zech

Zech

  • 3 Posts
  • 0 Reply Likes
  • confused

Posted 5 months ago

  • 1
Photo of Zech

Zech

  • 3 Posts
  • 0 Reply Likes
I've even tried uploading to a personal folder and receive the same issue. Is there another type of access needed to perform this type of integration?
Photo of Velu

Velu

  • 1 Post
  • 0 Reply Likes
Hello Zach, Can you please share some sample request/response failures?
Photo of Zech

Zech

  • 3 Posts
  • 0 Reply Likes
Velu thanks for the response. To begin with everything I'm retrieving a new access token based on the refresh token from my initial authentication. After I have the access token I'm able to successfully perform a few GET requests to retrieve the specific directory and parse the JSON response to get the "Id" for the directory. Once I have the Id I perform the following:

Make a POST request to: https://{subdomain}.sharefile.com/sf/v3/Items(${folder_id})/Upload

Where {subdomain} is my companies subdomain and ${folder_id} is the Id parsed from the JSON response of the GET. I pass the following HTTP Query Parameters as part of this POST:

method = standard
fileName = test.docx
fileSize = 7349 ---> in bytes
raw = true
overwrite = true

I get a 200 HTTP status when making the POST request and get a Chunk URI in the response. I parse the JSON response to get the ChunkUri and make a second POST request to the ChunkUri. I then set the request body with the attachment. When making this POST request I get a 403 HTTP Status with an error message of: "Forbidden username/password combo" and a response of: "You do not have permission to view this directory or page."

I have access to the folder and I can physically log in to my ShareFile domain and make any uploads to the folder that I'm trying to upload to in the POST request. I also am using the same credentials and obtaining new access tokens from the refresh token that was initially gained by using my credentials.