<rss version="2.0" xmlns:a10="http://www.w3.org/2005/Atom"><channel><title>Inflectra Customer Forums: Sample Code to do post and get requests using SpiraTeam Webservice using Ruby. (Thread)</title><description>&#xD;
Hi Guys,&#xD;
&#xD;
    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     &#xD;
&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
  /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)  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/abstract_response.rb:103:in `return!'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:860:in `process_result'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:776:in `block in transmit'  &#xD;
	 from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:853:in `start'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:766:in `transmit'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:215:in `execute'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:52:in `execute'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient.rb:67:in `get'  &#xD;
	 from webservicesample.rb:11:in `         Moreover I am not able to perform any GET or POST request. Please help!!!!!!!!  </description><language>en-US</language><copyright>(C) Copyright 2006-2026 Inflectra Corporation.</copyright><managingEditor>support@inflectra.com</managingEditor><category domain="http://www.dmoz.org">/Computers/Software/Project_Management/</category><category domain="http://www.dmoz.org">/Computers/Software/Quality_Assurance/</category><generator>KronoDesk</generator><a10:contributor><a10:email>support@inflectra.com</a10:email></a10:contributor><a10:id>http://www.inflectra.com/kronodesk/forums/threads</a10:id><ttl>120</ttl><link>/Support/Forum/spiratest/issues-questions/1546.aspx</link><item><guid isPermaLink="false">threadId=1546</guid><author>Droid Mann (rajthedaredevil@gmail.com)</author><category domain="http://www.inflectra.com/kronodesk/thread/tag">rest</category><category domain="http://www.inflectra.com/kronodesk/thread/tag"> api</category><category domain="http://www.inflectra.com/kronodesk/thread/tag"> ruby</category><title>Sample Code to do post and get requests using SpiraTeam Webservice using Ruby.</title><description>&#xD;
Hi Guys,&#xD;
&#xD;
    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     &#xD;
&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
  /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)  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/abstract_response.rb:103:in `return!'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:860:in `process_result'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:776:in `block in transmit'  &#xD;
	 from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:853:in `start'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:766:in `transmit'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:215:in `execute'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient/request.rb:52:in `execute'  &#xD;
	 from /usr/local/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0/lib/restclient.rb:67:in `get'  &#xD;
	 from webservicesample.rb:11:in `         Moreover I am not able to perform any GET or POST request. Please help!!!!!!!!  </description><pubDate>Tue, 04 Oct 2016 04:35:04 -0400</pubDate><a10:updated>2016-10-05T04:27:50-04:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1546.aspx</link></item><item><guid isPermaLink="false">messageId=2771</guid><author>Droid Mann (rajthedaredevil@gmail.com)</author><title>&#xD;
Tried the below url in soap UI still getting 'Request Error'&#xD;
&#xD;
    http://api.inflectra.com/Spira</title><description>&#xD;
Tried the below url in soap UI still getting 'Request Error'&#xD;
&#xD;
    http://api.inflectra.com/Spira/Services/v5_0/RestService.svc/users?username=xxxxxxxx&amp;api-key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx     Can some one please help???? </description><pubDate>Wed, 05 Oct 2016 04:27:48 -0400</pubDate><a10:updated>2016-10-05T04:27:48-04:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1546.aspx#reply2771</link></item><item><guid isPermaLink="false">messageId=2772</guid><author>Droid Mann (rajthedaredevil@gmail.com)</author><title>&#xD;
Tried the below url in soap UI still getting 'Request Error'&#xD;
&#xD;
    http://api.inflectra.com/Spira</title><description>&#xD;
Tried the below url in soap UI still getting 'Request Error'&#xD;
&#xD;
    http://api.inflectra.com/Spira/Services/v5_0/RestService.svc/users?username=xxxxxxxx&amp;api-key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx     Can some one please help???? </description><pubDate>Wed, 05 Oct 2016 04:27:50 -0400</pubDate><a10:updated>2016-10-05T04:27:50-04:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1546.aspx#reply2772</link></item></channel></rss>