问题
I am trying to convert a group of HTML documents to answer units with Watson's Document Conversion service. Approximately 1/3 of the documents process fine, with the remainder giving this error:
The Media Type [application/octet-stream] of the input document is not supported. Auto correction was attempted, but the auto detected media type [text/plain] is also not supported. Supported Media Types are: application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/pdf, text/html, application/xhtml+xml.
This occurs on the same documents (sample below), and happens whether I submit them via the watson-developer-cloud Node.js library or through the demo at https://document-conversion-demo.mybluemix.net/ with one exception: when using the online demo, if I rename the file with a .html extension before uploading it, it processes successfully.
I feel like I'm probably not doing something I should, such as explicitly stating the file type, but I can't figure out how to do that with the Node.js watson-developer-cloud library. The code I'm using looks like this:
document_conversion.convert(
{
file: {value: new Buffer(content), options: {}},
conversion_target: "ANSWER_UNITS",
type: "text/html"
},
function (err, response)
{
...
Can anyone help?
<p class=\"western\" lang=\"en-GB\" style=\"margin-top: 0cm;\"> <font size=\"3\">Find here a LIST OF COUNTRY CODES</font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <br> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">000 USA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">351 CENTERAL EUROPE & RUSSIA SSC</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">600 USA/PUERTO RICO</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">603 ALBANIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">607 ARMENIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">610 ANGOLA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">612 ALGERIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">613 ARGENTINA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">614 AFGHANISTAN</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">615 BANGLADESH</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">616 AUSTRALIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">618 AUSTRIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">619 BAHAMAS</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">620 BAHRAIN</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">621 BARBADOS/ANTIGUA/GRENADA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">624 BELGIUM/LUXEMBOURG</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">626 BELARUS</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">627 BERMUDA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">629 BOLIVIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">631 BRAZIL</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">636 BOTSWANA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">640 GUYANA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">643 BRUNEI</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">644 BULGARIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">645 BURUNDI</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">646 BURMA/MYANMAR</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">649 CANADA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">650 CAMEROON</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">651 GEORGIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">652 SRI LANKA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">655 CHILE</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">661 COLOMBIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">662 ZAIRE</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">663 COSTA RICA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">664 CONGO</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">666 CYPRUS</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">668 CZECH REPUBLIC</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">669 CABO VERDE</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">670 DJIBOUTI</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">672 CHINA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">677 DUBAI</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">678 DENMARK</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">680 UNITED ARAB EMIRATES</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">681 DOMINICAN REPUBLIC</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">682 GERMAN DEMOCRATIC RP</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">683 ECUADOR</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">688 CZECH REPUBLIC</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">693 SLOVAK REPUBLIC</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">694 KAZAKHSTAN</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">695 KIRGHIZIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">698 ETHIOPIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">699 BOSNIA-HERZEGOVINA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">702 FINLAND</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">704 CROATIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">705 MACEDONIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">706 FRANCE/FRENCH OVERSEAS OPNS</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">707 SERBIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">708 SLOVENIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">724 GERMANY</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">725 GHANA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">726 GREECE</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">731 GUATEMALA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">733 HAITI</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">735 HONDURAS</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">736 MACAU</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">738 HONG KONG</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">740 HUNGARY</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">742 ICELAND</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">744 INDIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">749 INDONESIA</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">750 IRAN</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">752 IRAQ</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">754 IRELAND</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">756 ISRAEL</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">757 IVORY COAST</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">758 ITALY/SEMEA ITALY</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">759 JAMAICA/CAYMAN ISLANDS</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">760 JAPAN</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">762 JORDAN</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">764 KENYA</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">766 KOREA</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">767 KUWAIT</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">768 LEBANON</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">769 MALAWI</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">770 LIBERIA</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">772 LIBYA</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">778 MALAYSIA</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">780 MALTA</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">781 MEXICO</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">784 MOROCCO</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">786 MOZAMBIQUE</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">787 MOLDOVA</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">788 NETHERLANDS</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">790 NEPAL</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">791 NETHERLANDS ANTILLES</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">796 NEW ZEALAND/FIJI</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">799 NICARAGUA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">804 NIGERIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">805 OMAN</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">806 NORWAY</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">808 PAKISTAN</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">811 PANAMA</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">813 PARAGUAY</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">815 PERU</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">818 PHILIPPINES</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">820 POLAND</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">821 RUSSIA/CIS</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">822 PORTUGAL</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">823 QATAR</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">825 ZIMBABWE</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">826 ROMANIA</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">828 SWITZERLAND</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">829 EL SALVADOR</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">831 RWANDA</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">832 SAUDI ARABIA</font></font> </p> <p lang=\"fr-FR\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">833 SIERRA LEONE</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">834 SINGAPORE</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">835 SOMALIA</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">838 SPAIN</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">840 TUNISIA</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">842 SUDAN</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">843 SURINAME</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">846 SWEDEN</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">848 SWITZERLAND/LIECHTENSTEIN</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">849 YEMEN - NORTH</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">850 SYRIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">851 TANZANIA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">852 VIETNAM</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">854 YEMEN - SOUTH</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">856 THAILAND</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">857 UGANDA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">858 TAIWAN</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">859 TRINIDAD</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">862 TURKEY</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">864 SOUTH AFRICA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">865 EGYPT</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">866 UNITED KINGDOM</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">869 URUGUAY</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">871 VENEZUELA</font></font> </p> <p lang=\"en-GB\" style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">876 YUGOSLAVIA (EX)</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">883 ZAMBIA</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <font face=\"Courier New, monospace\"><font size=\"2\">889 UKRAINE</font></font> </p> <p style=\"margin-bottom: 0cm;\"> <br> </p> <p style=\"margin-bottom: 0cm;\"> <br> </p>
回答1:
I posted a similar answer on your other question, but as of v1.7.0, this is now an officially supported feature of the library:
document_conversion.convert({
file: new Buffer(content),
content_type: "text/html",
conversion_target: "ANSWER_UNITS"
}, function (err, response) {
//...
});
Note that it's content_type
here (to be consistent with the rest of the library). The options.contentType
just happened to work because it was passed to request
unmodified, but this is now a tested and documented feature.
回答2:
There was actually two problems; I was using the wrong keyword and it was in the wrong place. Instead of type, I had to use contentType to describe the mime/type, and it had to be in the options field of the file parameter, like this:
document_conversion.convert({file: {value: new Buffer(content),
options: {type: "text/html"}},
conversion_target: "ANSWER_UNITS"
}, function (err, response) {...
Many thanks to Joe Kozhaya for setting me straight on this.
回答3:
Answer is right there in the error message. The supported data types are: Supported Media Types are: - application/msword - application/vnd.openxmlformats-officedocument.wordprocessingml.document - application/pdf - text/html - application/xhtml+xml
Your input data is being detected as text/plain, not text/html. So that is why a simple rename of the offending file to .html works, it is enough to get the underlying magic file to classify the input document as text/html, and not text/plain.
You can also force the input type as text/html by using the parameter "type=text/html" on the API call. So I would suggest doing that with any of your "plain text" files. Better to leave those input files with their original names.
See the API documentation (https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/document-conversion/api/v1/) for more details.
来源:https://stackoverflow.com/questions/37104208/why-do-i-get-415-errors-from-watsons-document-conversion-service-on-certain-doc