Inflectra Customer Forums: Sample Code to do post and get requests using SpiraTeam Webservice using Ruby. (Thread) Hi Guys, I tried to perform a get request with SpiraTeam REST Webservice 5.0 with below code require 'net/http' require 'openssl' require 'stringio' require 'uri' require 'zlib' require 'rest_client' response = RestClient.get 'http://api.inflectra.com/Spira/Services/v4_0/RestService.svc',{'username':'xxxxxxxx', 'api-key':'{xxxxxxx-xxxxx-xxxx-xxxx-xxxx-xxxxxxxx}', 'Content-Type':'application/json', 'accept':'application/json', } puts response.body This work fine and service gets created. However when i perform a 'GET' request like get the username with my user id present in SpiraTest I am getting 400 Bad Request error. require 'net/http' require 'openssl' require 'stringio' require 'uri' require 'zlib' require 'rest_client' response = RestClient.get 'http://api.inflectra.com/Spira/Services/v4_0/RestService.svc/users/{xx:xxxx} ',{'username':'xxxxxxxx', 'api-key':'{xxxxxxx-xxxxx-xxxx-xxxx-xxxx-xxxxxxxx}', 'Content-Type':'application/json', 'accept':'application/json', } puts response.body I am getting the below error /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/abstract_response.rb:223:in `exception_with_response': 400 Bad Request (RestClient::BadRequest) from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/abstract_response.rb:103:in `return!' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:860:in `process_result' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:776:in `block in transmit' from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:853:in `start' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:766:in `transmit' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:215:in `execute' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:52:in `execute' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient.rb:67:in `get' from webservicesample.rb:11:in ` Moreover I am not able to perform any GET or POST request. Please help!!!!!!!! en-US(C) Copyright 2006-2024 Inflectra Corporation.support@inflectra.com/Computers/Software/Project_Management//Computers/Software/Quality_Assurance/KronoDesksupport@inflectra.comhttp://www.inflectra.com/kronodesk/forums/threads120/Support/Forum/spiratest/issues-questions/1546.aspxthreadId=1546Droid Mann (rajthedaredevil@gmail.com)rest-api webservice ruby Sample Code to do post and get requests using SpiraTeam Webservice using Ruby. Hi Guys, I tried to perform a get request with SpiraTeam REST Webservice 5.0 with below code require 'net/http' require 'openssl' require 'stringio' require 'uri' require 'zlib' require 'rest_client' response = RestClient.get 'http://api.inflectra.com/Spira/Services/v4_0/RestService.svc',{'username':'xxxxxxxx', 'api-key':'{xxxxxxx-xxxxx-xxxx-xxxx-xxxx-xxxxxxxx}', 'Content-Type':'application/json', 'accept':'application/json', } puts response.body This work fine and service gets created. However when i perform a 'GET' request like get the username with my user id present in SpiraTest I am getting 400 Bad Request error. require 'net/http' require 'openssl' require 'stringio' require 'uri' require 'zlib' require 'rest_client' response = RestClient.get 'http://api.inflectra.com/Spira/Services/v4_0/RestService.svc/users/{xx:xxxx} ',{'username':'xxxxxxxx', 'api-key':'{xxxxxxx-xxxxx-xxxx-xxxx-xxxx-xxxxxxxx}', 'Content-Type':'application/json', 'accept':'application/json', } puts response.body I am getting the below error /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/abstract_response.rb:223:in `exception_with_response': 400 Bad Request (RestClient::BadRequest) from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/abstract_response.rb:103:in `return!' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:860:in `process_result' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:776:in `block in transmit' from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:853:in `start' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:766:in `transmit' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:215:in `execute' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:52:in `execute' from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient.rb:67:in `get' from webservicesample.rb:11:in ` Moreover I am not able to perform any GET or POST request. Please help!!!!!!!! Tue, 04 Oct 2016 04:35:04 -04002016-10-05T04:27:50-04:00/Support/Forum/spiratest/issues-questions/1546.aspxmessageId=2771Droid Mann (rajthedaredevil@gmail.com) Tried the below url in soap UI still getting 'Request Error' http://api.inflectra.com/Spira Tried the below url in soap UI still getting 'Request Error' http://api.inflectra.com/Spira/Services/v5_0/RestService.svc/users?username=xxxxxxxx&api-key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Can some one please help???? Wed, 05 Oct 2016 04:27:48 -04002016-10-05T04:27:48-04:00/Support/Forum/spiratest/issues-questions/1546.aspx#reply2771messageId=2772Droid Mann (rajthedaredevil@gmail.com) Tried the below url in soap UI still getting 'Request Error' http://api.inflectra.com/Spira Tried the below url in soap UI still getting 'Request Error' http://api.inflectra.com/Spira/Services/v5_0/RestService.svc/users?username=xxxxxxxx&api-key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Can some one please help???? Wed, 05 Oct 2016 04:27:50 -04002016-10-05T04:27:50-04:00/Support/Forum/spiratest/issues-questions/1546.aspx#reply2772