SharePoint REST API response with wrong format

SharePoint REST API response with wrong format
0

Upvotes

Upvote

 Oct 13 2023
0 Comments 
New

I tried to send api
GET https://{tenant-name}-my.sharepoint.com/_api/v2.0/me/drive/root:%2F%E9%99%84%E4%BB%B6%2FL%C2%81ftungs-%2BKlimaanlagen

to get folder info in my OneDrive for Business.

Since folder's name contains illegal characters, this api failed.
(folder name after url encode:"L%C2%81ftungs-%2BKlimaanlagen")
However, the response of this api was html form with lack of information.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii">
</HEAD>
<BODY>
<h2>Bad Request - Invalid URL</h2>
<hr>
<p>HTTP Error 400. The request URL is invalid.</p>
</BODY>
</HTML>

 

Then, I tried to create folder by api with the same folder name
POST https://{tenant-name}-my.sharepoint.com/_api/v2.0/me/drive/items/01O3PQSUYXU2DBOOL6ORGKPWO3T7X3T4SF/children

I received the response with error message "The provided name cannot contain any illegal characters."

{
    "error": {
        "code": "invalidRequest",
        "message": "The provided name cannot contain any illegal characters."
    }
}

I have three question for this issue.
1. Why did I get different response from these two api with the same folder name?
2. Why was the response of first api with html form?
3. According to the document, I did not use any illegal characters. Why did I receive this error?

Thank you.