Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

how to handle chinese in ETM API

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

0 votes

Comments

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.

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>

 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

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.

0 votes

Comments

 Hi, David Honey 

Still the same error after converting to rdf+xml

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 log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,952

Question asked: Jul 09 '23, 10:38 p.m.

Question was seen: 901 times

Last updated: Jul 11 '23, 4:08 a.m.

Confirmation Cancel Confirm