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.

    Known Participant
    December 16, 2021

    I honestly don't know what to say. If you go to the Body tab, do you see *anything*? Here's what I see.

     

     

     


     

    I think I see the source of our confusion. Here is what I have as the value. I had mentioned this earlier but this was taken straight from the Extract PDF postman collection. This is what I input as part of my request. I get nothing back as a response save the error message in JSON.