500 (Internal Server Error with fileupload API)

  • 1
  • Question
  • Updated 2 months ago
  • (Edited)
I am trying the request call from the local environment. It is working properly in Postman.  but getting this error

POST https://mycompany.sf-api.com/sf/v3/Items(fo8582e7-1170-46ac-b1b6-f7ee11029a48)/Upload 500 (Internal Server Error)
Failed to load https://mycompany.sf-api.com/sf/v3/Items(fo8582e7-1170-46ac-b1b6-f7ee11029a48)/Upload: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 500.

Here is my request

$.ajax({
url: 'https://mycompani.sf-api.com/sf/v3/Items(fo8582e7-1170-46ac-b1b6-f7ee11029a48)/Upload',
type: 'POST',
data: {
Method: 'Standard',
raw: true,
filename: filename,
filesize: size
},
success: function (result) {
alert(result.success); // result is an object which is created from the returned JSON
},
});
Photo of Nidhi

Nidhi

  • 3 Posts
  • 0 Reply Likes

Posted 2 months ago

  • 1
Photo of Binod Thakur

Binod Thakur

  • 8 Posts
  • 0 Reply Likes
Hi Nidhi,

I have used it with java code. Uploading is the two way process, in 1st call it returns Chunk URI and then again you have to make one more call on Chunk URI then file is getting uploaded.

In Postman also it's two way process. Just wanna know how have to tried in Postman?

POST https://mycompany.sf-api.com/sf/v3/Items(fo8582e7-1170-46ac-b1b6-f7ee11029a48)/Upload, this call will return Chunk URI, it won't upload the file. You have to make one more call on Chunk URI.


Regards,
Binod

Photo of Nidhi

Nidhi

  • 3 Posts
  • 0 Reply Likes
@Binod Thakur,

yeah, I followed that two-way process. I have tried it in Postman. It is working as expected.

I guess this error is occurring due to a cross-origin issue in javascript. Because I am calling the API from local to Sharefile server using js.
(Edited)