Modify an input

If a job is not yet started, you may need to patch it to modify the inputs. You can reach the goal by sending an input PATCH request to the endpoint:

/v2/jobs/<job_id>/input/<input_id>

with the new data inside the body like in the following example.

Let's assume that your job with id 60056999-6cb9-4301-8c91-0247036f2098 has an input with id d163a942-465d-4f0f-9d96-e05dce7bd686 that looks like the following:

"input": [{
    "id": "d163a942-465d-4f0f-9d96-e05dce7bd686",
    "type": "remote",
    "source": "https://example-files.online-convert.com/document/pdf/example_multipage_protected.pdf",
    "size": 1096348,
    "hash": "e84a82fb5f42391c57d9411b21671a87",
    "checksum": "e84a82fb5f42391c57d9411b21671a87",
    "content_type": "application/pdf",
    "created_at": "2018-10-02T08:45:21",
    "modified_at": "2018-10-02T08:45:22",
    "parameters": [],
    "metadata": {
        "pdf_has_user_password": true,
        "password_protected": true
    }
}]

As you can see in the metadata section, the PDF is password protected, so we cannot process it. At this point, you can still add the password before starting the conversion by sending a PATCH request like the following:

PATCH /v2/jobs/60056999-6cb9-4301-8c91-0247036f2098/input/d163a942-465d-4f0f-9d96-e05dce7bd686 HTTP/1.1
Host: api.api2convert.com
x-oc-api-key: <your API key here>
Content-Type: application/json
Cache-Control: no-cache

{
    "credentials": { 
        "decrypt_password": "online-convert.com" 
    } 
}

If the password is the right one, you will immediately receive the answer from the API which should look like the following.

{
    "id": "d163a942-465d-4f0f-9d96-e05dce7bd686",
    "type": "remote",
    "source": "https://example-files.online-convert.com/document/pdf/example_multipage_protected.pdf",
    "filename": "example_multipage_protected.pdf",
    "size": 1096348,
    "hash": "e84a82fb5f42391c57d9411b21671a87",
    "checksum": "e84a82fb5f42391c57d9411b21671a87",
    "content_type": "application/pdf",
    "created_at": "2018-10-02T08:45:21",
    "modified_at": "2018-10-02T08:47:12",
    "parameters": [],
    "metadata": {
        "pages": "7",
        "page_size": "595 x 842 pts (a4)",
        "pdf_password_valid": true,
        "pdf_password_conversion_permission": true,
        "password_protected": true
    }
}

As you can see, the metadata now contains more useful information, like the number of pages and the size, that proof that we can now access and process the file.

results matching ""

    No results matching ""