Simple HTTP Requests in Code

Class library usage, coding and language questions.
lukeclewlow
Posts: 3
Joined: Thu Dec 08, 2016 4:52 pm

Simple HTTP Requests in Code

Post by lukeclewlow » Thu Dec 08, 2016 4:59 pm

Hi there,

I am new to C# and Ranorex and want to do something seemingly very simple but not quite sure how to go about doing it.

I want to hit an API endpoint before I start each test, as this will ensure the application is in the correct state for the test to take place. I just want this to be an action I can pass a variable to at the start of a test module, which will complete before moving on to the next test step.

I have written some very simple verification methods as "user code" in Ranorex before so am familiar with how to add user code methods in their simplest form.

Thanks in advance for your help.

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: Simple HTTP Requests in Code

Post by RobinHood42 » Wed Dec 21, 2016 9:26 am

Hi lukeclewlow

I'm would suggest to check out the following articles:
Cheers,
Robin

Martin
Posts: 152
Joined: Fri Aug 15, 2014 12:24 pm

Re: Simple HTTP Requests in Code

Post by Martin » Wed Dec 21, 2016 2:09 pm

Well there isn't much else than to just understand a C# HTTP request and handle the response. There are loads of materials on these topics.

From the response you could either fail or succeed the test and have correct Error behaviour set up to either continue or stop the test flow.

So basically, just make the request, capture the response and from the response either fail or succeed the test.

If the API actually works on WSDL level, you could create a web reference out of it and have the functionality inside of the test suit for other test case use as well.

But try to understand first how C# handles HTTP requests and responses.