23 Answers, 1 is accepted
Before I say whether or not Test Studio can help you what does "Web API testing" mean to you? What exactly are you trying to test? Are you planning to make HTTP calls to verify a web service is functioning? Or are you planning to make API calls directly? How do you want to make these calls? What results will you want to verify and how do you want to verify them?
Regards,
Cody
Telerik
Thank you for the clarification. I don't think Test Studio, our full IDE is going to be the right solution for you. Test Studio was designed to do UI automation, to drive a browser window, or WPF application, as if a real person were sitting there interacting with it directly. It does this through UI automation. We don't have built-in method for making direct GET and POST call's and validating the responses.
If it were me I'd use either our free framework or create a Microsoft coded unit test to do this. Either way you'll need to write your own code for making the GET and POST call's and validating the responses.
Regards,
Cody
Telerik
Found this post by searching "API Testing" and thought I would reply for posterity's sake.
Check out my code sample and see if that helps.
http://www.telerik.com/support/code-library/testing-rest-api-using-test-studio
Hi,
I use the following code in my project for Rest GET and POST calls. Hope this works for you too! :)
GET METHOD:
public String get(String restURL, Boolean AuthFlag, string UserName, string password)
{
Manager.Current.Log.WriteLine("*********** RESTURL**********" + restURL);
var request = WebRequest.Create(restURL);
request.Method = "GET";
request.ContentType = "application/json";
var networkCredential = new NetworkCredential(UserName, password);
request.Credentials = networkCredential;
string responsetext = null;
try
{
using (var response = request.GetResponse())
{
Debug.WriteLine(((HttpWebResponse)response).StatusDescription);
var receiveStream = response.GetResponseStream();
var readStream = new StreamReader(receiveStream, Encoding.UTF8);
Manager.Current.Log.WriteLine("Response stream received.");
responsetext = readStream.ReadToEnd();
Manager.Current.Log.WriteLine(responsetext);
response.Close();
readStream.Close();
return responsetext;
}
}
catch (Exception e1)
{
Manager.Current.Log.WriteLine(e1.Message);
Manager.Current.Log.WriteLine(responsetext);
}
return responsetext;
}
POST METHOD:
public string Post(string restURL, Boolean AuthFlag, string payload, string UserName, string password)
{
Manager.Current.Log.WriteLine("****** restUrl *****" + restURL);
Manager.Current.Log.WriteLine("****** payload *****" + payload);
var request = WebRequest.Create(restURL);
request.Method = "POST";
var postData = payload;
var byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/json";
var networkCredential = new NetworkCredential(UserName, password);
request.Credentials = networkCredential;
var dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
var response = request.GetResponse();
Debug.WriteLine(((HttpWebResponse)response).StatusDescription);
dataStream = response.GetResponseStream();
var reader = new StreamReader(dataStream);
var responseFromServer = reader.ReadToEnd();
Manager.Current.Log.WriteLine(responseFromServer);
reader.Close();
dataStream.Close();
response.Close();
return responseFromServer;
}
Thank you for sharing your knowledge with our community.
We really appreciate it!
Thank you again!
Regards,
Boyan Boev
Telerik
Hi Pravallika/Boyan/TIM,
I found this post while searching in the net how to test the Web API for my project through Telerik Test Studio. I am using Telerik Test Studio for Functional testing. How I can use this code and where I need to write this to do my testing. I have never used the coding while doing the testing. I am using only recording. Could you please guide me how to incorporate the coding part.I would really appreciate for your help.
Thanks,
Satya
Thank you for contacting us.
This is some custom implementation which we do not support.
@Pravalika could you please give us some information about your approach.
@Satyanarayan we will introduce API Testing as part of Test Studio during the next releases this year and it will be officially supported.
Hope that helps.
Regards,
Boyan Boev
Telerik
can we use telerik for API testing. Please let me know is it possible or not.
Thanks
We are now implementing this functionality in Test Studio.
It is expected to go live in June this year.
Hope that helps.
Regards,
Boyan Boev
Telerik
Hi
I want to automate my APIs like i want to test my API request and responses using Test Studio. But i am not able to get the option to do the same. So please let me know if API funtional automation testing is possible using Test Studio.
Thanks
This functionality will be available in Test Studio in June this year.
We are now implementing it.
Thank you for your understandings.
Regards,
Boyan Boev
Telerik
Hi Suraj,
You can automate Web API testing using RESTSHARP & NewtonSoft. There are very simple http calls that you need to make and easy to code. I have attached a sample of what we have done on our project.
If you don't have Visual Studio, the the latest version of Test Studio can be used for your automation. You need to take help from your developers in understanding on how to make calls and create POCO.
In my case, i have stored all the data in an excel spread sheet, parse the sheet, use NewtonSoft to serialize and Deserialize the objects (POCO). I also store all the JSONs for completeness and correctness.
Hope this helps, have attached a sample. You need to include the libraries for restsharp & newtonsoft.
You may use Telerik Fiddler which can also be used to automate WebAPI. This is more simple, there is an article on Telerik site
http://www.telerik.com/blogs/api-testing-with-telerik-fiddler
cheers
govind
The release which includes the API testing is expected at the end of this month.
This will be a complete API testing solution, which of course will be improved with a lot of new features in the feature release. We are constantly improving our products.
Thank you!
Regards,
Boyan Boev
Telerik
Hello Suraj,
You can try using RestSharp & NewtonSoft, they are simple to use. Your developer should be able to set this up for you in quick time.
Unfortunately the admin on telerik removed my last post.
regards
govind
You post is not removed, it is right above mine. We do not remove any post from our customers especially when it is a knowledge sharing.
Thank you for sharing your knowledge with the community.
Regards,
Boyan Boev
Telerik
Telerik Team,
From past few weeks am working on your tool: Test Studio for APIs, there are so many things which are not clear in your document guide and webinar demo. This tool is new for me in terms of API testing. I would really appreciate if I can get some solutions on my following queries from your team with respect to this tool:
1. Does Telerik Test Studio for APIs supports Web API testing?
2. How do I pass the Web API URL to perform some GET and POST methods? (Should I simply add it as a base-url under Project?).
3. While accessing some sample APIs like Google Maps (geocode) or Youtube API, it shows an Proxy Authorization issue status i.e. 407. This is blocking me from exploring the tool and its features.
4. Your built-in demo application has no clear definition as to how it is connected with the tool. If I want to connect such .exe or console application with the tool, how should I proceed?
Kindly help me with some solution as my organization is looking forward to use Test Studio API tool for future API projects.
Here are my comments on your topics:
1. Test Studio for APIs supports any REST service so if you mean testing a REST service based on ASP.Net Web Api you should be able to test it.
2. You can add it directly as a url, or you can create a project or test-level variable.
3. Probably your APIs need some kind of authorization. Based on the type of authorization, in most cases you can use an Authorization header with an access token to perform the authorized request. This is specific and you need to research what kind of authorization these APIs require.
4. The demo application is designed to send requests against it for testing purposes. Here is an article for the demo project in Test Studio for APIs.
I hope this information will be helpful to you.
Regards,
Elena Tsvetkova
Telerik by Progress
Hi Elena,
Thank-you for helping me out, your comments have solved most of my queries.
Regards,
Jyoti Shanbal
I am glad to hear the shared information was helpful to you. Feel free to contact Test Studio Support Team in case of any further queries.
Regards,
Elena Tsvetkova
Telerik by Progress
Could you please advice on this scenario.
Thanks
Subhash
Recently you have started another public thread on the same topic and since the discussion there is already in progress, I will proceed closing the current conversation as a duplicate one.
Thank you for your understanding in advance.
Regards,
Elena Tsvetkova
Progress Telerik