Can't delete media that is in use via api, even with forceDelete = 1

Trying to delete a video, from the library, that is in a playlist that is assigned to a layout that is currently playing.

I’m using the /api/library/{mediaId} path with the DELETE method. I’m sending multipart form data and setting ‘forceDelete’ to 1

The response is a 422 Unprocessable Entity “This library item is in use”

I’ve tried setting forceDelete to 1, “1”, 0, and true. I get the same result for all values of forceDelete.

I do want the media removed from the library and any and all playlists/layouts, am I using forceDelete wrong?

Thanks.

I’d need to see your request code to be sure, but at a guess you’re not passing it with
application/x-www-form-urlencoded

Alternatively you could use our oauth2 wrappers, namely this one as every wrapper goes through request() function it will have the proper parameters passed with the calls.

I do appreciate that our oauth may not look overly great at the moment, there are severe changes coming to it, including a lot better shot at explaining the wrappers, documentations, logs etc.

In any case, I do think that you’re missing the application/x-www-form-urlencoded in your call.

Thanks for the reply.

I am able to upload, assign to a playlist, and schedule the playlist with no issues.

I was not passing application/x-www-form-urlencoded, but even with it added, I am getting the same results. I tried sending JSON as well, to match the generated example in the Swagger documentation and still no luck. The httpClient is a Guzzle client.

        $this->httpClient->request(
                'DELETE',
                $this->xiboHost."/api/library/$mediaId",
                [
                    'headers' => [
                        'Authorization' => 'Bearer '.$this->getToken(),
                        'content-type' => 'application/x-www-form-urlencoded',
                    ],
                    'multipart' => [
                        [
                            'name' => 'forceDelete',
                            'contents' => 1,
                        ],
                    ],
                ]
            );

You will want to use form_params with calls that use application/x-www-form-urlencoded instead of the multipart.

so something like:

    $response = $guzzle->request('DELETE', 'http://192.168.0.26/api/library/1223', [
        'headers' => [
            'Authorization' => 'Bearer ' . $token,
            'Content-type' => 'application/x-www-form-urlencoded'
        ],
        'form_params' => [
            'forceDelete' => 1
        ]
    ]);

Thanks for the suggestion and the example. I tried form_params - still getting the 422.

I tried using curl to try and remove as many variables as possible (taken from the swagger example):

curl -X DELETE "http://myxibo.compmany.com/api/library/41" -H "accept: application/json" -H "content-type: application/json" -H "Authorization: Bearer b5Vy5nw16ZmVQlUlLzTB5nCKhlpAgbT5DQRcPPwf" -d "forceDelete=1"

Curl returns

{
    "error": {
        "message": "This library item is in use.",
        "code": 422,
        "data": [

        ]
    }
}

Updated the cms from 1.8.2 to 1.8.5 hoping that might fix it, still no dice.

That is rather odd, I think we will need to look at it from the web ui side as well.

Can this file be deleted from web ui (with the checkbox enabled)?

If yes:

You can also navigate to the logs page, switch channel to API in filter and see what’s logged there when you execute your script (obviously in this case with different mediaId)

If not

Navigate to the Log page and see what’s logged when you try to delete it via web ui

Yes I tried yesterday to delete it via the web ui to ensure that it was working there. It deletes fine from the web ui.

I also tried to delete items via the api that had been added via the web ui, to ensure that I wasn’t doing something wrong when I was uploading via the api. Still couldn’t delete via the api, if the media is assigned.

It deletes as expected using the api if the media is not assigned.

Nothing is being logged when the 422 return code is generated.

I’m using the docker install, with an external mysql database, just for further info.

Thanks again for all the help.

Your content-type is wrong - its actually application/x-www-form-urlencoded not json, i.e. (forceDelete=1)