Skip to main content
Question

Cannot move, rename, files or foder 405 returned

  • May 22, 2025
  • 2 replies
  • 21 views

Forum|alt.badge.img

API calls are made with Postman:

cUrl version:

curl --location --request PUT 'https://upload.box.com/api/2.0/folders/12858XXX9798' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer R3Tw4fOBrEPlGl3k7mxxx0Ty0yE41PeP' \
--data-raw '{
"name": "New folder name"
}'

Okhttp version (my case in my app):

OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"name\": \"New folder name\"\r\n }");
Request request = new Request.Builder()
.url("https://upload.box.com/api/2.0/folders/12858XXX9798")
.method("PUT", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer R3Tw4fOBrEPlGl3k7mxxx0Ty0yE41PeP")
.build();
Response response = client.newCall(request).execute();

The call has exactly the same structure as on: https://developer.box.com/reference/put-folders-id/ 

Response : 405 method not allowed??

Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
Allow: OPTIONS, POST, GET, HEAD
Strict-Transport-Security: max-age=31536000

Method PUT not allowed???

I have tried with POST: return 415!

After spending hours on this simple call ... I wonder if there is not a problem with your server?

Note that I have no problem with all my other requests: uploads, chunk uploads, list, delete, copy etc ...

Any help would be really appreciated.

Thank you in advance.

2 replies

Forum|alt.badge.img

Hi Stéphane

It looks to me like you are using the https://upload.box.com endpoint for your rename folder call. This endpoint is only for uploading files. For any other API actions such as update, rename or move you need to use https://api.box.com

So it should work like this: 

curl --location --request PUT 'https://api.box.com/api/2.0/folders/12858XXX9798' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer R3Tw4fOBrEPlGl3k7mxxx0Ty0yE41PeP' \
--data-raw '{
"name": "New folder name"
}'

Hope this helps

Best regards, Peter Christensen, Platform Solutions Engineer

 


Forum|alt.badge.img

Thanks Peter,
it's my fault (a bad copy pasted!) the error was under my nose and yet I did not see it !!

On the other hand it is also necessary to remove the "/ api /":

"https://api.box.com/2.0/folders/"+folderId