INVALID_MULTIPART_REQUEST

New Here ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

$response = Http::withHeaders([
'Authorization' => 'Bearer XYZ',
'X-API-Key' => 'ABC123',
'Content-Type' => 'multipart/form-data',
])->post('https://cpf-ue1.adobe.io/ops/:create', $data);

 

In Laravel i'm trying the endpoint to create a PDF. I use the example data from the document services api documentation: https://documentcloud.adobe.com/document-services/index.html#post-documentGeneration

 

{
"cpf:engine": {
"repo:assetId": "urn:aaid:cpf:Service-52d5db6097ed436ebb96f13a4c7bf8fb"
},
"cpf:inputs": {
"documentIn": {
"dc:format": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"cpf:location": "InputFile0"
},
"params": {
"cpf:inline": {
"outputFormat": "pdf",
"jsonDataForMerge": {
"customerName": "Kane Miller",
"customerVisits": 100,
"itemsBought": [
{
"name": "Sprays",
"quantity": 50,
"amount": 100
},
{
"name": "Chemicals",
"quantity": 100,
"amount": 200
}
],
"totalAmount": 300,
"previousBalance": 50,
"lastThreeBillings": [
100,
200,
300
],
"photograph": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP88h8AAu0B9XNPCQQAAAAASUVORK5CYII="
}
}
}
},
"cpf:outputs": {
"documentOut": {
"dc:format": "application/pdf",
"cpf:location": "multipartLabel"
}
}
}

 

I get the following reply:

 

array:5 [  "requestId" => "fmbhttWQ9VUrmMYuuz2sMjvc28CclxA1"
  "type" => "Bad Request"
  "title" => "Not a multipart request. Aborting."
  "status" => 400
  "report" => "{"error_code":"INVALID_MULTIPART_REQUEST"}"]

 

What's wrong here?

TOPICS
Document Generation API

Views

460

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

Hi @agence rosseelr32959105,

 

Thanks a lot for trying out our Product and providing for your valudable inputs. To ease out the "Getting started" with our APIs, we have captured Template postman collection with each API in the documentation  https://documentcloud.adobe.com/document-services/index.html.

The $data needs to be a multipart object (Please refer Form Parameters section inside API definition for POST documentGeneration endpoint) -

1. contentAnalyserRequests - containing the JSON schema you have defined above.

2. InputFile0 - The docx file part that is to be converted to PDF.

 

Alternatively, please try out our Node JS SDK interface which eases out the process of document generation even further -

Samples - https://github.com/adobe/pdfservices-node-sdk-samples

Sample code for reference - https://github.com/adobe/pdfservices-node-sdk-samples/blob/master/src/documentmerge/merge-document-t...

SDK - https://www.npmjs.com/package/@adobe/pdfservices-node-sdk

 

Hope this helps.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

LATEST
Belinda Beasley

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources