It's all about the answers!

Ask a question

how to handle chinese in ETM API


zjx zjx (11) | asked Jul 09 '23, 10:38 p.m.

When post requests to ETM API to create test cases or test scripts, the request body contains Chinese error reports.

"The element type "ns2:steps" must be terminated by the matching end-tag "</ns2:steps>", After encoding Chinese in utf-8, the same error occurs. How to include Chinese in the request body and display it normally in the system


Comments
David Honey commented Jul 10 '23, 4:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

As with all questions about REST APIs, please provide details of the request URI, request headers, request body (if applicable), and the response body and headers you got.


zjx zjx commented Jul 10 '23, 4:26 a.m.

request url:https://localhost/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/<project>/testscript


request header: {'OSLC-Core-Version': '2.0', 'Accept': 'application/xml', 'Content-Type': 'application/rdf+xml'}

request body:
<?xml version="1.0" encoding="UTF-8"?>
.
.
<ns4:title>\xe6\xb5\x8b\xe8\xaf\x95\xe6\xad\xa5\xe9\xaa\xa4</ns4:title>
<ns2:description>description</ns2:description>
<ns2:steps>
<ns8:step>
<ns8:name>\xe6\xb5\x8b\xe8\xaf\x95\xe6\xad\xa5\xe9\xaa\xa4</ns8:name>
<ns8:title>\xe6\xb5\x8b\xe8\xaf\x95\xe6\xad\xa5\xe9\xaa\xa4</ns8:title>
<ns8:description>description</ns8:description>
</ns8:step>
</ns2:steps>
</ns2:testscript>


zjx zjx commented Jul 10 '23, 4:32 a.m.

 reponse header:{'Date': 'Mon, 10 Jul 2023 08:27:41 GMT', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload, max-age=31536000', 'X-Powered-By': 'Servlet/3.1', 'x-com-ibm-team-scenario': '192.168.22.1', 'Connection': 'close', 'Transfer-Encoding': 'chunked', 'Content-Type': 'application/xml', 'Content-Language': 'en-US'}

partial response body:<ns2:statusCode>400</ns2:statusCode><ns2:message>The uploaded content does not consist of well-formed XML or does not match the XML schema for testscript</ns2:message><ns2:trace>javax.xml.bind.UnmarshalException\n - with linked exception:\n[org.xml.sax.SAXParseException: The element type "ns8:step" must be terminated by the matching end-tag "&lt;/ns8:step&gt;".] javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:350)\ com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:593) com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:267) 

One answer



permanent link
David Honey (1.8k17) | answered Jul 10 '23, 1:04 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jul 10 '23, 1:05 p.m.

Your POST request has a Content-Type header of application/rdf+xml but the body is not valid RDF/XML. You can use online RDF validation/conversion tools such as https://www.easyrdf.org/converter to check.


Comments
zjx zjx commented Jul 10 '23, 9:26 p.m.

 Hi, David Honey 

Still the same error after converting to rdf+xml


David Honey commented Jul 11 '23, 4:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Your XML is not well formed. If I copy what you provided into https://codebeautify.org/xml-parser-online I see it has errors. For example, <ns2:testscript xmlns:ns2="http://jazz.net/xmlns/alm/qm/v0.1/" is missing the closing > .  The validator reports:
 

I suggest you use online validators to make make sure that your POST body content is well-formed.

Your answer


Register or to post your answer.