Batching Multiple Attribute/All Metadata requests

Attempting to batch setMultipleAttributes and setMetadataAllFields seems to result in errors. I'm not sure if this is intentional, if there is some error in the logic that parses them, or if there is another issue with parameters being passed to the batch version of functions.


From experimentation, it seems that calling setMetadataAllFields is faster than multiple calls to setMetadata, so I'd prefer to call it once than sending individual batch functions through, but can do individual calls if needed. Similarly, setMultipleAttributes seems faster than multiple calls.



Is this an intentional limitation which isn't in the documentation, or a problem with the API?



The error messages it gives are:

setMultipleAttributes: { error="Please enter both the attribute name and value" }

setMetadataAllFields: { error="Please enter both the field id and value"}



In both cases, the data provided is exactly the same as that provided to the standalone, working, version.

Can you show us how you are making the call to setMultipleAttributes? E.g.:

    js_api.setMultipleAttributes({
       "asset_id":"100",
       "field_info":{
      "name":"New Name",
      "short_name":"New Short Name"
       },
       "dataCallback":customDataCallbackFunc
    }) 

Sure. For the single call, it's:

    
    var attributes = {
      "name":"Example asset",
      "short_name": "Example short name"
    };
    js_api.setMultipleAttributes({
          "asset_id": assetid,
          "field_info": attributes
        });


This works perfectly. For the batch request:

    
    var attributes = {
      "name":"Example asset",
      "short_name": "Example short name"
    };
    js_api.batchRequest({
      "functions":{
    "0": {
      "function": "setMultipleAttributes",
      "args":{
        "asset_id": assetid,
        "field_info": attributes
      }
    }
      }
    });


As far as I can tell, these two statements should be functionally equivalent, but with the second allowing for the next call to become part of the same request, minimising http connections required, but the second doesn't work, even when provided with exactly the same attributes block as the first. I've also tried changing "asset_id" to "id", in common with some of the other JS API functions, but that didn't make any difference.

For the moment, I've gone back to issuing single setMetadata and setAttribute calls through the batchRequest function, which seems to work, and is taking about 8 seconds for all attributes, metadata and links to save, which is a lot quicker than making the changes through the back end, or even using Easy Edit.


Would still be interested in whether this is an intentional limitation or a bug though!