v6.58.0
Hi,
I’m trying to use the JS API with the createFileAsset and updateFileAssetContents operations. There also appears to be a dependency - acquireLock, which I’ve included in my batch request.
According to the docs, I should be able to retrieve the asset id from the createFileAsset operation, and use it in the subsequent acquireLock and updateFileAssetContents operations to udpate the file asset that was created.
Unfortunately, not matter which way I try to combine the %results_0_param% keyword, I keep getting the following error (highlighted in yellow):
I’ve tried a whole load of different combinations, following the docs:
- “
%" + "Results_0_id" + "%
” - “
%" + "results_0_id" + "%
” - “
%" + "results_0_0_id" + "%
” - “
%" + "Results_0_0_id" + "%
” - “%Results_0_id%”
- “%Results_0_0%”
- “%results_0_id%”
- “%results_0_0%”
- “%results_0_0_id%”
Kinda predictably, the ones with capital ‘R’ don’t get replaced, and instead cause the error property in the response to return ’%Results_0_0_id%
is not a valid URL’ instead for example.
I’m assuming the first 0 refers to the index of the operation in the batchRequest setup - 0 for the output of the first function, 1 for the output of the second, and so on. In addition, the second 0 (it it’s used), designates the location of the property in the call’s response. The createFileAsset operation outputs the following on success:
… where the bits in yellow are the asset ids. Because the createFileAsset’s response doesn’t explicitly contain ‘id’ property, the _0_id% alternatives above would appear to be irrelevant. I thought perhaps it would be the index within the response in that case, so I tried _0_0% but that didn’t return anything either.
Here’s the final batchRequest before I left off:
js_api.batchRequest({
"functions":{
"0":{
"function":"createFileAsset",
"args":{
"parentID":"X",
"type_code":"File",
"friendly_name":"reminder33.ics",
"link_type":"SQ_LINK_TYPE_1",
"link_value":"link value"
},
"blocking":1
},
"1":{
"function":"acquireLock",
"args":{
"asset_id":"%results_0_0_0%",
"screen_name":"",
"dependants_only":0,
"force_acquire":1
},
"blocking":1
},
"2":{
"function":"updateFileAssetContents",
"args":{
"asset_id":"%results_0_0_0%",
"content":"aGVsbG8sIHdvcmxk", // "Hello, world"
}
}
},
"dataCallback":printObject
});
Any ideas?