Skip to main content
Known Participant
December 15, 2021
Question

Incorrect contentAnalyzerRequests json values = 400 status "invalid JSON in request"

  • December 15, 2021
  • 1 reply
  • 5540 views

Working in Postman and going off of the Postman Collection for that particular service, the problem arises for both HTML to PDF request and Extract PDF requests. I have valid auth bearer token and nothing else seems amiss.

 

My contentAnalyzerRequests value for HTML to PDF: 

 

{\n  \"cpf:inputs\": {\n    \"params\": {\n      \"cpf:inline\": {\n        \"print\": {\n          \"includeHeaderFooter\": true\n        },\n        \"pageLayout\": {\n          \"pageHeight\": 8.5,\n          \"pageWidth\": 11\n        },\n        \"json\": \"{\\\"k1\\\": \\\"v1\\\", \\\"k2\\\": \\\"v2\\\"}\"\n      }\n    },\n    \"documentIn\": {\n      \"cpf:location\": \"InputFile0\",\n      \"dc:format\": \"application/zip\"\n    }\n  },\n  \"cpf:engine\": {\n    \"repo:assetId\": \"urn:aaid:cpf:Service-e2ee120a2b06427cb449592f5db967e7\"\n  },\n  \"cpf:outputs\": {\n    \"documentOut\": {\n      \"cpf:location\": \"multipartLabelOut\",\n      \"dc:format\": \"application/pdf\"\n    }\n  }\n}

 

My contentAnalyzerRequests value for Extract PDF:

 

{\n    \"cpf:engine\": {\n        \"repo:assetId\": \"urn:aaid:cpf:58af6e2c-1f0c-400d-9188-078000185695\"\n    },\n    \"cpf:inputs\": {\n        \"documentIn\": {\n            \"cpf:location\": \"InputFile0\",\n            \"dc:format\": \"application/pdf\"\n        },\n        \"params\": {\n            \"cpf:inline\": {\n                \"elementsToExtract\": [\n                    \"text\", \"tables\"\n                ],\n                \"renditionsToExtract\": [ \"tables\", \"figures\"]\n            }\n        }\n    },\n    \"cpf:outputs\": {\n        \"elementsInfo\": {\n            \"cpf:location\": \"jsonoutput\",\n            \"dc:format\": \"application/json\"\n        },\n        \"elementsRenditions\": {\n            \"cpf:location\": \"fileoutpart\",\n            \"dc:format\": \"text/directory\"\n        }\n    }\n}

 

It could be that I don't understand what I'm doing with regard to these values. Do they need to be adjusted based on whatever PDF is being fed to it?

    This topic has been closed for replies.

    1 reply

    Raymond Camden
    Community Manager
    Community Manager
    December 15, 2021

    Any chance you can share those code snippets in either a Gist, or, use the Insert Code button when editing your message and then paste it in. That should keep the line breaks and remove the \n.

     

    Known Participant
    December 15, 2021

    Unfortunately not in this case. I used the code sample feature when plugging the JSON in, but there isn't a JSON option so I went with HTML. I have uploaded the JSON files, however, for each API service in question. It's there that I copy-pasted the values associated with each contentAnalyzerRequests.

    Raymond Camden
    Community Manager
    Community Manager
    December 16, 2021

    2 things: "I tried importing from Postman but the schema I input provided in the Extract collection can't be read by Postman." That's odd. Any chance you are running an older version of Postman? Any chance when you downloaded it, the browser messed with it?

     

    Second issue is much simpler - you need to pick a file for InputFile0. See it there as the second option?

    You need to actually pick a file.

     


    For item one - no. Use the downloaded JSON file (the one you shared above), in Postman, Import, and pick the file. 

     

    I had no problem submitting the call to Extract using the PDF you attached below.

     

    Honestly it sounds like the biggest issue is how you are importing the collection into Postman. Can you try the file import? You then need to run the Exchange JWT portion, get your bearer token, and use that (and your client id) in the "Submit" call.