Developer forum

Forum » Dynamicweb 10 » /admin/api/FileCreateRename is not allowed

/admin/api/FileCreateRename is not allowed

Joakim
Reply

Hi,
Our client is running 10.25.6 and we've built a custom addIn in which we want to create a file via custom JS.
Attempting to use the endpoint /admin/api/FileCreateRename is not allowed and message says file already exists(when it doesnt).
When attempting to test it in Api explorer it throws error: Unknown layout type: 'CommandExecute'.

Any insight is much appreciated,
Thanks



Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Can you share the payload you send when seeing this?

 
Joakim
Reply

This is the payload:

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Thanks

I have looked at it. Andf that command is confusing - I agree...

The root problem is your payload — you are passing model.name: 'settings' which triggers rename mode. The correct payload for creating a new file is:

const payload = {
  name: 'settings.json',   // ← the Command.Name (desired filename)
  model: {
    name: '',              // ← empty = new file (not rename)
    directoryPath: '/Files/System',
  }
}

I have changed the command - so first of all you would get a Invalid status and not "NotAllowed" which is technically incorrect.

I have also added 2 additional checks giving you a precise error when the payload is 'wrong':

  • "Operation failed. The file '{model.Name}' does not exist."
  • "Operation failed. The file '{Name}' already exists."

For compatbility reasons we cannot change the command to be more explicit on rename or new.

Votes for this answer: 1
 

 

You must be logged in to post in the forum