REST API Batch Update Fails on url (file/link) Field

I can update a single entity path field but when I try to batch request it, I get this error:

{u'errors': [{u'status': 400, u'code': 104, u'title': u'Update failed for [PublishedFile.path]: Value is not legal.', u'detail': None, u'source': None, u'meta': None, u'id': u'2b9c4e5305098c21ca587adf19c1f9c0'}]}

Example of code in python:

def do_it(file_id=106418):
    auth = get_shotgun_auth_token(SCRIPT_NAME, SCRIPT_KEY, SHOTGUN_URI)

    headers = {
        'Content-Type': 'application/json'
    }
    headers.update(auth)

    update_resp = requests.put(
        SHOTGUN_URI + '/api/v1/entity/PublishedFile/' + str(file_id),
        data=json.dumps(
            {
                'path': {
                    "local_path": "V:\\test\\path\\TEST.pdf",
                    "local_path_linux": "/mnt/vfx/test/path/TEST.pdf"
                }
            }
        ),
        headers=headers
    )
    print(update_resp.json())  # Success

    batch_req = [
        {
            'request_type': 'update',
            'entity': 'PublishedFile',
            'record_id': file_id,
            'data': {
                'path': {
                    "local_path": "V:\\test\\path\\TEST.pdf",
                    "local_path_linux": "/mnt/vfx/test/path/TEST.pdf"
                }
            }
        }
    ]

    batch_resp = requests.post(
        SHOTGUN_URI + '/api/v1/entity/_batch',
        headers=headers,
        data=json.dumps({'requests': batch_req})
    )
    print(batch_resp.json())  # Error

I’m admittedly less familiar with the REST API but I know from the Python API that when updating a Local File Link on an Attachment field as you are, local_path_linux is read-only. SG will automatically select the matching LocalStorage for Linux. So the only path you should be sending is local_path which should match your current local path (assuming Windows here).

However, even with that adjustment, I’m seeing the same issues you are. In fact when doing a read request for the PublishedFile, the “path” field doesn’t display the local_path attribute like the Python API does. In the Python API, this is a convenience attribute that always returns the path for the current OS.

But there’s definitely something not consistent with the batching method here. I tried all sorts of combinations without success and getting the same exact issue you see :confused: Sorry I’m no help.

For reference, here’s the Python API info I referred to:

https://developer.shotgunsoftware.com/python-api/cookbook/attachments.html#creating-updating-local-file-fields

cheers,
kp

1 Like

Ahh good point linux path was not needed here. Batch request problem still persists however. This feels like a bug with shotgun’s REST API backend unless I’m still missing something silly.

Would be great if someone from Shotgun could step in here. This is a road blocker in our pipeline, need to get it fixed.