Share via

Bug in download.aspx - wrong status code on error

Anonymous
2016-12-05T14:17:05+00:00

When trying to download a file from e.g. 

https://***********-my.sharepoint.com/personal/***************/_layouts/15/download.aspx?guestaccesstoken=somethingwhichhasexpired&docid=034d5d845fffe2222ba54db9b6c38be61

the page shows an error message, but at the same time, the HTTP status code is 200.

In this instance, it is correct that the URL should cause an error, as the document does not exist anymore. The problem is that the status code does not signal an error. As I am creating a service which is downloading from a temporarily shared file, my service obviously reads the status code 200, stores the error HTML code, and tells me that the download was successful. To work around this, I currently have to check the size of the file, and look for various parts of the HTML code, and hope that my selected error markers don't change.

* Is this a local problem in the instance I am using, or is this a global bug in OneDrive for Business?

* Who can fix this, or report it as a bug in the right forum?

* What will be the expected time frame for such a fix?

Thank you for helping me out,

Arve

[PII Masked by Michael Macayan MSFT Moderator - Monday, 2:39PM UTC 12/05/2016]

Microsoft 365 and Office | OneDrive | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

10 answers

Sort by: Most helpful
  1. Anonymous
    2016-12-09T12:10:21+00:00

    Respectfully, I must say that you are completely wrong here. It is not ok to return 200 OK with an error message. That is what "all" the other status codes are for.

    This is even specified in Microsoft REST API Guidelines:

    > As part of onboarding to Microsoft REST API Guidelines, services MUST comply with the taxonomy defined below.

    > Errors, or more specifically Service Errors, are defined as a client passing invalid data to the service and the service correctlyrejecting that data. Examples include invalid credentials, incorrect parameters, unknown version IDs, or similar. These are generally "4xx" HTTP error codes and are the result of a client passing incorrect or invalid data.

    [...]

    >Services SHOULD be able to be accessed from simple HTTP tools such as curl without significant effort.

    MDN has a nice readable overview of the HTTP status codes.

    A few relevant examples:

    > 200 OK (GET): The request has succeeded. The resource has been fetched and is transmitted in the message body.

    > 400 Bad Request: This response means that server could not understand the request due to invalid syntax.

    > 401 Unauthorized: Authentication is needed to get requested response. This is similar to 403, but in this case, authentication is possible.

    > 404 Not Found: Server can not find requested resource. This response code probably is most famous one due to its frequency to occur in web.

    > 500 Internal Server Error: The server has encountered a situation it doesn't know how to handle.

    I understand that your task is to stop noise from reaching the actual developers. This is an actual bug report, for a silly mistake that shouldn't take more than a few minutes to fix. It might be one of the most common mistakes in web APIs, but that does not make it any less wrong.

    The result of MS not fixing it, is that everyone integrating with OneDrive for Business will have to write code to compensate for the error. The API breaks the HTTP standard, and does not comply with Microsoft's own API guidelines. If that is something you're happy with; by all means, ignore this feedback. I have other options.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2016-12-06T14:12:00+00:00

    Hi

    This is not really a bug with the File Picker SDK, but a bug with the download.aspx route, which I presume is a component of Sharepoint (aka OneDrive For Business). It is true that the file picker SDK (Javascript, runs in the browser) communicates with OneDrive for Business to produce these links.

    This is the third forum in which I try to kindly report to Microsoft that there's a bug in your API, and am told to try somewhere else. Do I understand it correctly that the interest in fixing this kind of bugs is limited?

    Now I am not sure how OneDrive for Business is sewn together, and therefore do not know if this is a config problem with the SharePoint instance, or a global defect. Given that this is a cloud service, I wouldn't expect the local admins were responsible to edit download.aspx, and therefore I tried contacting MS about this.

    Are you sure that this cannot be handled in this forum?

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2016-12-06T13:32:48+00:00

    Hi Arve Skogvold,

    Since this is related on the File Picker SDK that needs to be downloaded to integrate OneDrive for Business, I suggest you post your question on our MSDN Forum for more detailed help.

    We appreciate your understanding.

    Thanks,

    Mike

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2016-12-06T10:43:06+00:00

    Hi

    Thanks for a quick reply.

    This is a download from OneDrive for business, using a link similar to the one provided by the file picker in https://dev.onedrive.com/sdk/js-v7/js-picker-overview.htm -- it is provided to us by a third party, and I'm not completely sure how it's generated. They often work, but when they expire, the problem appears.

    This is not something the average user would be affected by, as this is an API problem. If one of the OneDrive For Business developers is shown the error; i.e. that this url gives an error but returns status code 200, I expect that the problem would be understood.

    Here's a screenshot highlighting the problem

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2016-12-05T15:28:33+00:00

    Hi Arve Skogvold,

    To narrow down the issue, I'd like to confirm the following:

    1. Are you downloading a file from a OneDrive for Business online site?
    2. Can you provide a step by step procedure on how you achieve this? A screenshot of the issue with steps will be helpful, for us to better understand your situation.

    As for your concerns, we need to identify if this is happening to all OneDrive for Business users. You may need to provide a more detailed explanation or description of the issue on how you encounter it.

    Thanks,

    Mike

    Was this answer helpful?

    0 comments No comments