Skip Navigation LinksHome Page > Forums > SpiraTeam Forums > SpiraTeam Issues & Qu... > Accessing Spira test usin...
Hi Manoj
Please try this out:
https://www.inflectra.com/Support/KnowledgeBase/KB49.aspx
Regards
Adam
Hi Adam,
I am going through this example. But this example uses SOAP services. However i am looking for rest api which i am able to connect through java code.
public final String BASE_URL = "http://api.inflectra.com/Spira/Services/v4_0/RestService.svc"; public final String USER_NAME = ""; public final String API_KEY=""; public static void main( String[] args ) { try { ClientConfig clientConfig = new DefaultClientConfig(); Client client = Client.create(clientConfig); WebResource resource = client.resource(BASE_URL);// resource.header("username", USER_NAME);// resource.header("api-key", API_KEY); resource.queryParam("username", USER_NAME); resource.queryParam("api-key", API_KEY); ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); System.out.println(response.getStatus()); } catch (Exception e) { e.printStackTrace(); }
this is my sample code for connecting spira rest url. i am getting exception as fallows
com.sun.jersey.api.client.ClientHandlerException: java.net.UnknownHostException: api.inflectra.com at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:155) at com.sun.jersey.api.client.Client.handle(Client.java:652) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509) at com.iDRT.controller.SpiraConnection.main(SpiraConnection.java:34)Caused by: java.net.UnknownHostException: api.inflectra.com at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.<init>(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at java.net.HttpURLConnection.getResponseCode(Unknown Source) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:253) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:153) ... 5 more
And if you have any questions, please email or call us at +1 (202) 558-6885