0

For POST method I have this piece of code in LR (it is working):

web_custom_request(transname,
URL,
"Method=POST",
"TargetFrame=",
"Mode=HTML",
"Resource=0",
"Referer=",
EncodingType,
lr_eval_string(request),
LAST);

This piece of code is placed in a separated .c file and called from user_init using a long sequence of related functions working with XML, arrays, strings data.

URL for POST requests has structure in user_init like this: URL=https://{HOST}/aaa/bbb/page.asp

Also user_init contains this piece of code:

web_custom_request("Login_page",
"URL=http://{HOST}/api/04_00/Pr_NAME.asp",
"Method=POST",
"RecContentType=text/xml",
"Body="
"<?xml version=\"1.0\"?>"
"<Request    xmlns=\"http://api.rr.com/Pr_NAME\">\r\n"
"  <MethodRequest>\r\n"
"    <AuthenticateUserRequest appID=\"value_appID\" password=\"value_password\">\r\n"
"      <User>\r\n"
"        <LoginName>value_LoginName</LoginName>\r\n"
"      </User>\r\n"
"    </AuthenticateUserRequest>\r\n"
"  </MethodRequest>\r\n"
"</Request>\r\n", 
LAST);

I need something additional to this code, that will allow to send both POST and GET requests to web-service. Now it sends only POST requests.

There are some questions:

1) How should I change this function to get the possibility to send both types of requests, POST and GET? What strings should I add to this function?

2) How should I change the URL for GET requests?

I think, it should be something like this:

URL=https://{HOST}/aaa/bbb/page.asp?param1=value1&param2=value2...&paramN=valueN

But what parameters should I add as param1, param2, ..., paramN?

How to define, how many and what parameters I need put in this URL construction?

Should I write this structure:

URL=http://{HOST}/api/04_00/Pr_NAME.asp?appID=value_appID&password=value_password&LoginName=value_LoginName

or shouldn't I add LoginName=value_LoginName in this structure?

3) How can I combine both 2 methods POST and GET in 1 function, to have the possibility to send both types of requests, POST and GET, from LR?

Please, could you help me? I'm a novice in data transferring in LR using POST and GET methods and functions.

ucMedia
  • 4,105
  • 4
  • 38
  • 46
Nadezhda T
  • 262
  • 8
  • 24

3 Answers3

1

Here are some answers (not entirely related to LR). 1) POST and GET are HTTP verbs that tell the server what you expect it to do with your request. There is no rules on what the server should do but instead conventions. The conventions are: GET - Tells the server: Please give me data related to the parameters I provide in the querystring. POST - Tells the server: Here is some data in the body of this request, please do something with it (usually but not always create a record of something). There is no sense of sending both types of verbs in the same request. In any case to set the verb use the "method" parameter (in your example it says "Method = POST" so you can change it to "Method = GET".

2)GET request sometimes needs parameters. As a convention you don't send those parameters in the Body but in a structure called querystring which comes after the URL separated by "?". The querystring is a list of parameter name and its value. Please google "querystring" for more information. The parameters you should use are the ones expected by the server. You have to ask the server creator about which parameters to send.

3) As I mentioned above, this doesn't make sense.

Hope this helps.

Buzzy
  • 2,905
  • 3
  • 22
  • 31
  • Thanks a lot for your explanation, especially in the 1st part. I spent a lot of time reading articles (usualy, in php) before I visualize this schema. You have very easy and understanable language to explain. 2) Are the parameters in GET request, which server is expecting in querystring, written anywhere on the server? Should I conclude, that server checks at first parameters in querystring and compare them with required list of parameters on server and than, if they are matched, server send some information as answer to this request? 3) Yes, I see. Thanks! – Nadezhda T May 22 '13 at 14:58
  • 1
    2) I don't know of a way without asking the server implementer. For the second question, yes. It's like a function in C, it expects several parameters and if you don't provide them then something bad might happen. – Buzzy May 23 '13 at 13:14
0

Since you likely have recorded this conversation, the natural question to ask why you would want to alter the request method in your application code to something else other than what is deployed? This is a break in your test between deployed and test and would need to be noted with your test results.

James Pulley
  • 5,606
  • 1
  • 14
  • 14
  • My goal is to write (or rewrite) functions which can send GET requests, to learn how to do realisation of this action using C in LR. Therefore I need information what I must change in code for receiving this result. This task is like self-study. – Nadezhda T May 22 '13 at 15:10
0

Requests' method should either POST or GET or other types of methods. There should NOT be both. I understand that you are doing self-study, but it is protocol violation.

NaveenKumar Namachivayam
  • 1,163
  • 3
  • 25
  • 39