photools.com Community

IMatch Discussion Boards => IMatch Scripting and Apps => Topic started by: axel.hennig on March 16, 2022, 11:13:08 PM

Title: v1/files/copy not working anymore
Post by: axel.hennig on March 16, 2022, 11:13:08 PM
Hi everybody,

due to the fact that I'm an absolute beginner regarding JavaScript / IMatch programming I'm not sure if this is a bug or if I just don't know how I get this to work.

I've got an app (since 2-3 years) which uses the v1/files/copy endpoint. The app always worked as expected, but right now it is not working anymore (IMatch 2021.15.2).

I've tested the following code in Chrome:
http://127.0.0.1:50519/v1/files/copy?auth_token=&id=1&absolutepath=D:

This gives the following error in the browser:

{
"error":{
  "code":1101,
  "message":"Unknown or unsupported method."
}
}Error 404: Not Found
Not found


When running an app with v1/files/copy it returns (in DevTools) an error 400 (Bad request) and refers to jquery.min.js:2 (I guess the 2 means line 2).

Due to my limited programming skills I'm not able to get deeper into this.

My question: Could someone please check if the v1/files/copy endpoint is working (and how)?

Thanks
Title: Re: v1/files/copy not working anymore
Post by: Mario on March 17, 2022, 09:17:32 AM
This is a POST request. You cannot make POST requests with your web browser.

No change in this endpoint for a long time, and a quick test shows that it works just fine. I've used this code to copy the selected file(s) to a folder in my database:

IMWS.post('v1/files/copy',{
    idlist: IMatch.idlist.fileWindowSelection,
    targetpath: 'C:\\data\\Image\\Test',
}).then(function(response) {
    console.log(JSON.stringify(response,null,2));
},function(error) {
    console.log(JSON.stringify(error,null,2));
});
Title: Re: v1/files/copy not working anymore
Post by: axel.hennig on March 17, 2022, 09:24:16 PM
Thanks Mario, together with the code you provided I was able to get it to work.