Answer
If you are using PrizmDoc Server in cluster (multi-server) mode, and you are using Content Conversion Services to merge multiple files into one, or whenever multiple file ids using multiple affinity tokens need to be combined; your requests need to use a single affinity token. Because affinity tokens need to go in the header, you might think you are required to include all/both of the files’ affinity tokens in the header.
If you find yourself in this situation, the correct method is to re-use the first affinity token you get for all subsequent resources you create. For example, if you create a work file, you’ll get an affinity token back in the response. That affinity token needs to be set in the Accusoft-Affinity-Token
request header of any subsequent resources (work files, content converter, viewing sessions, etc.) that you create later and want to use together.
An example is located here:
https://help.accusoft.com/PrizmDoc/latest/HTML/affinity-tokens-and-cluster-mode.html
The main takeaway here is that the initial request that is made to the server for a workfile will return an affinity token. This very same affinity token must be used in the header Accusoft-Affinity-Token
for all subsequent requests in this conversion/stitching process.
The most relevant quote from that page is:
“In cluster mode, the PrizmDoc Server API will automatically generate an affinity token when it receives a POST request for a new ViewingSession, WorkFile, MarkupBurner, RedactionCreator, or ContentConverter resource and return it in the response. Once you have obtained an affinity token, you will need to pass this in with related requests using the Accusoft-Affinity-Token
HTTP custom header.”
Here is a separate custom example of stitching two TIFF images together by converting them to a PDF.
First TIFF image
Request with no affinity token:
POST /PCCIS/V1/WorkFile HTTP/1.1
Host: prizmdocservername:18681
Content-Type: application/octet-stream
Response:
{
"fileId": "I3GRFEfrw_K8fX4VJ7Z1bQ",
"fileExtension": "tif",
"affinityToken": "ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc="
}
Second TIFF image
Request:
POST /PCCIS/V1/WorkFile HTTP/1.1
Host: prizmdocservername:18681
Content-Type: application/octet-stream
Accusoft-Affinity-Token: ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc=
Response:
{
"fileId": "I-CTRdFnaL8FLNQDUawTHw",
"fileExtension": "tif",
"affinityToken": "ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc="
}
Content Conversion
Request:
POST /v2/contentConverters HTTP/1.1
Host: prizmdocservername:18681
Content-Type: application/json
Accusoft-Affinity-Token: ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc=
{
"input": {
"sources": [
{
"fileId": "I3GRFEfrw_K8fX4VJ7Z1bQ"
},
{
"fileId": "I-CTRdFnaL8FLNQDUawTHw"
}
],
"dest": {
"format": "pdf"
}
}
}
Response:
{
"input": {
"dest": {
"format": "pdf",
"pdfOptions": {
"forceOneFilePerPage": false
}
},
"sources": [
{
"fileId": "I3GRFEfrw_K8fX4VJ7Z1bQ",
"pages": ""
},
{
"fileId": "I-CTRdFnaL8FLNQDUawTHw",
"pages": ""
}
]
},
"expirationDateTime": "2018-10-03T19:12:52.005Z",
"processId": "1u6k5Y_l7yRfhWyfL1t4Yw",
"state": "processing",
"percentComplete": 0,
"affinityToken": "ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc="
}
Content Conversion Request:
/v2/contentConverters/{processId}
GET /v2/contentConverters/1u6k5Y_l7yRfhWyfL1t4Yw HTTP/1.1
Host: prizmdocservername:18681
Accusoft-Affinity-Token: ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc=
Content Conversion Complete Response:
{
"input": {
"dest": {
"format": "pdf",
"pdfOptions": {
"forceOneFilePerPage": false
}
},
"sources": [
{
"fileId": "I3GRFEfrw_K8fX4VJ7Z1bQ",
"pages": ""
},
{
"fileId": "I-CTRdFnaL8FLNQDUawTHw",
"pages": ""
}
]
},
"expirationDateTime": "2018-10-03T19:12:52.005Z",
"processId": "1u6k5Y_l7yRfhWyfL1t4Yw",
"state": "complete",
"percentComplete": 100,
"output": {
"results": [
{
"fileId": "tK4UbzryHWFoqOC6JJAjAg",
"sources": [
{
"fileId": "I3GRFEfrw_K8fX4VJ7Z1bQ",
"pages": "1"
},
{
"fileId": "I-CTRdFnaL8FLNQDUawTHw",
"pages": "1"
}
],
"pageCount": 2
}
]
}
}
Download The WorkFile:
/PCCIS/V1/WorkFile/{fileId}
GET /PCCIS/V1/WorkFile/1u6k5Y_l7yRfhWyfL1t4Yw HTTP/1.1
Host: prizmdocservername:18681
Accusoft-Affinity-Token: ZSTudgjA42h1CVCj0KkGuYiKn5nEFhmFrvA0AkMxDxc=