Difference between Put and Post in IEM CLI

Been playing around with the IEM CLI and I’m getting an unexpected result when I try to update a site file.

I uploaded a small text file with the CLI using: iem post .\test.txt site/custom/Test/file/test.txt and it returns the xml result with the file ID that was generated.

Name: test.txt
ID: 5028871

I then tried to use the put command to update the test.txt file using: iem put \testupd.txt site/custom/Test/file/5028871

But instead of updating the existing file it generated a new file with a new file ID and the original test.txt file’s ID as the name.

Name: 5028871
ID: 5028872

If I try the same Put cmd line again (iem put \testupd.txt site/custom/Test/file/5028871 ) it gives the error:
API Request Failed: Attempt to create a file on site ‘Test’ with the same name ‘5028871’ of one already existing.

Out of curiosity, I tried the same cmd line with Post (iem post \testupd.txt site/custom/Test/file/5028871) and it gives the same error as above.

Am I misunderstanding how this is supposed to work or is it a bug? I going by the examples and descriptions on the developer site for the rest-api calls: https://developer.bigfix.com/rest-api/api/site.html and I’m currently running v9.2.8.74


It is as the {file id} in the put command is 5028871 in Your example

site/{site type}/{site name}/file/{file id}

is managed as the {file name} in the POST command

site/{site type}/{site name}/file/{file name}

So the first time the file with name 5028871 is created assigning a new ID ( casually is 5028871 + 1 ) … then attempting another PUT the command fails because a file with that name already exists.

Could be … quite … because then attempting to provide a “file name” is not a number the command fails:

./iem put /tmp/file.my /api/site/master/file/file.my
API Request Failed: String found where a integer ID expected.

So it is as something is wrong, probably make sense open a PMR and let the dev team work on it … http://www-01.ibm.com/support/docview.wss?uid=swg21505708

On the other side to update a file has been already loaded can use the --force option of POST command using the iem cli or directly the rest api:

iem post /tmp/file.my /api/site/custom/test/file/file.my --force=yes
curl -k -u master:****** -X POST -F “file=@/tmp/mytestfile.out” “https://tem-PC:52311/api/site/custom/test/file/file.my?force=true

Note that the key/value pair is case-sensitive and any difference respect the expected one is managed as the default ( --force=no in this case ) without any advice

It is available a --isClientFile=true option as well to upload ‘client files’:

iem post c:/Temp/test.bat /api/site/custom/mycustom/file/file.my --isClientFile=true
curl -k -u master:****** -X POST -F “file=@/tmp/file.my” “https://tem-PC:52311/api/site/custom/test/file/file.my?force=true;isClientFile=true

… this option can be also used in conjunction with --force option if need …

Finally with rest api is possible upload more then one file with a single command ( the same with the iem cli is not so easy to do ):

curl -k -u master:**** -X POST -F “file=@/tmp/a.txt” -F “file=@/tmp/b.txt” “https://tem-PC:52311/api/site/custom/mycustom/files

These and some further examples on this topic are going to be added to the following doc page with an apar IV94605 has been recently opened:

Hopefully these info start to be of help …


It would seem that using the undocumented “–force=yes” switch for the IEM CLI makes all of the difference.

If the command is not forced the put or post simply creates a new file with the + 1. If the file ID does exist it updates the contents as expected.

Thanks for the tip.

1 Like

I know this is much later, but between this post and the IEM samples, I wanted to note that we can POST multiple files with curl and still get the overwrite behavior.

curl -k -u myoperator -X POST -F "file=@c:\temp\file1.txt" -F "file=@file2.txt" "https://mybesserver.mydomain.com:52311/api/site/custom/MyCustomSite/files?force=true;isClientFile=false"

We can also specify a target filename when doing uploads one at a time
curl -k -u myoperator -X POST -F "file=@c:\temp\file1.txt" "https://mybesserver.mydomain.com:52311/api/site/custom/MyCustomSite/file/mytargetfilename.txt?force=true;isClientFile=false"


We can get the Overwrite behavior with multiple files, but isClientFile doesn’t seem to have an effect.

curl.exe -k -u myuser -X POST -F "file=@Facility.txt" "https://myserver:52311/api/site/custom/Holding/files?force=true;isClientFile=true"

  • Overwrites the existing file, but does not Send to Clients

curl.exe -k -u myuser -X POST -F "file=@Facility.txt" "https://myserver:52311/api/site/custom/Holding/file/Facility.txt?force=true;isClientFile=true"

  • Overwrites the existing file, and Sends to Clients