It's all about the answers!

Ask a question

Getting 400 Bad requestion while connecting to RQM via API


Vidhya Venkatesan (3117) | asked Nov 07 '16, 11:02 p.m.
RQM connection is successful after that adding header and trying to POST gives error.
the request body is an xml, and the xml is converted and given as input stream.attached the code below. Kindly help in solving the issue.

for the connection.doPost(fis, l, "xml"); i have tried all the combinations for content type like application/xml, XML, .xml and text/xml. while debugging inside the api methods i found the response of execute method is given 400 . till that the execution and the URI receiving happens correctly.

try {

      connection = rawRestServiceClient.getConnection(uri);

 

      connection.addRequestHeader("Slug", "49");

      connection.addRequestHeader("Referer", "https://rb-alm-05-d.de.bosch.com/qm");

      connection.addRequestHeader("Content-Type", "application/xml");

      connection.addRequestHeader("Accept", "application/xml");

      InputStream fis = null;

      ByteArrayOutputStream os = new ByteArrayOutputStream();

      int b;

 

      try {

        fis = new FileInputStream(

            new File("C:\\temp\\vid3cob\\workspace\\orion\\8.0.1\\workspace\\com.bosch.almmig.reqone\\Testplan.xml"));

      }

      catch (FileNotFoundException e) {

        // TODO Auto-generated catch block

        LOGGER.error("Rqone query prefix is not encoded properly", e);

      }

      try {

        if (fis != null) {

 

          while ((b = fis.read()) != -1) {

            os.write(b);

          }

          // connection.doGet();

          Long l = new Long(os.size());

          // connection.doPost(fis, l, "xml");

 

          connection.doPost(fis, l, "xml");

        }



Comments
Donald Nong commented Nov 08 '16, 12:45 a.m.

Have you checked the response body, or the qm.log file on the server for more detailed information?


Vidhya Venkatesan commented Nov 08 '16, 1:04 a.m.

Hi Donald,
is this the one

com.ibm.team.repository.common.transport.TeamServiceException: CRJAZ2942E A request from this server to another server could not be completed. The other server returned a 400 HTTP error with this error text: Bad Request.
    at com.ibm.team.repository.transport.client.RemoteTeamServer.throwHttpClientError(RemoteTeamServer.java:2105)
    at com.ibm.team.repository.transport.client.RemoteTeamServer.executeMethod(RemoteTeamServer.java:1296)
    at com.ibm.team.repository.transport.client.RemoteTeamServer.executeMethod(RemoteTeamServer.java:1121)
    at com.ibm.team.repository.transport.client.RestClientConnectionBase.executeMethod(RestClientConnectionBase.java:375)


Donald Nong commented Nov 08 '16, 1:10 a.m.

Not likely. You should just reproduce the problem and check the latest message in the qm.log file.

One answer



permanent link
Paul Slauenwhite (8.4k12) | answered Nov 17 '16, 7:23 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Are you using the RQM OSLC API or RQM Reportable REST API?  To use the OSLC API, you'll need specific headers (see https://jazz.net/wiki/bin/view/Main/RqmOslcQmV2Api#Headers).  I would suggest using your favorite browser plugin to issue HTTP requests (e.g. Poster/HttpRequester) to learn how to use the API before using a code example.

Your answer


Register or 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.