Getting 400 Bad requestion while connecting to RQM via API
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
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
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
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.