Setting metadata: Can I set meta for different files in one call?

Started by ubacher, July 21, 2017, 06:50:10 AM

Previous topic - Next topic

ubacher

I am passing the following tag array to IMWS.post('v1/metadata',

  [
  {
    "id": 755556,
    "op": "set",
    "tag": "datecreated",
    "value": "2017:07:20 17:19:01.0233"
  },
  {
    "id": 755559,
    "op": "set",
    "tag": "datecreated",
    "value": "2017:07:20 17:17:18.0400"
  },
  {
    "id": 755561,
    "op": "set",
    "tag": "datecreated",
    "value": "2017:07:20 17:17:20.0861"
  }
]

Each id is different. Is this allowed? it replaces only the first one I find.

thrinn

Should work. Just tried with the following coding, and it sets the rating of both files as expected. Did you stringify the tasks array correctly?

            IMWS.post("v1/metadata", {
                tasks: JSON.stringify([
                    {
                        "id": 26,
                        "tag": "rating",
                        "op": "set",
                        "value": 2
                    },
                    {
                        "id": 27,
                        "tag": "rating",
                        "op": "set",
                        "value": 2
                    }

                ])
            })
Thorsten
Win 10 / 64, IMatch 2018, IMA

Mario

id can be a single id, a comma-separated list of ids or an array of ids.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ubacher

Lack of understanding on my part:
Changing 'datecreated' is changing XMP::Photoshop\DateCreated


After writing out metadata the create date/time is changed.

Mario

Mapping between XMP and EXIF/IPTC/EXIF only happens during write-back.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ubacher

Quoteid can be a single id, a comma-separated list of ids or an array of ids.
Only for writing metadata or in general? I tried the following but it gives a bad request error (no file specified)

console.log(JSON.stringify(idarr))
                   IMWS.post('v1/metadata/writeback',{
                        scope: 'files',
                        id: idarr             
                    }).then(function(response) {.......


where idarr shows as:
[755621,755624,755626]

Am I doing something wrong?

Mario

Not in general. I thought you were talking about the POST metadata call and what the task object supports.

The id parameter takes a lit of one of more file ids. '1,2,3' not a JSON array. The id parameter is used in many contexts, e.g. in regular URLs for get calls. URLs don't support JSON objects. You can use join to convert your array into a comma-separated list.

The task object (sic!) is a JSON object and sent via the POST body. Different thing. I decided to be flexible and support an array in addition to the comma-separated list of ids for this parameter. This don't meant that it works in general, especially not for endpoints which use URLs (GET request).
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ubacher

A related question: what is the structure of an idlist?
Can I generate one myself or can I only use the provided ones?

Mario

Check out the documentation for the /idlist endpoints. The 'automatic' idlists maintained by IMWS are just a special case of general idlists. For example, the "Likes" in IMatch WebViewer use an idlist.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ubacher

I had a look:
To generate an idlist I need a comma separated list of id's.
But if I have that id list in my script why would I bother to generate an idlist?

Mario

idlists can be stored and later retrieved (to maintain a list of ids beyond the lifetime of your app). idlists can also automatically validate themselves, e.g. to ensure that the ids stored in them are still valid. If you only need your list of ids while your app runs, you don't need idlists.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook