0

I have a web_custom_request method that needs to handle dynamic item data

web_custom_request("create", 
    "URL=someurl\create", 
    "Method=POST", 
    "Resource=0", 
    "RecContentType=application/json", 
    "Referer=someurl", 
    "Snapshot=t6.inf", 
    "Mode=HTML", 
    "EncType=application/json", 
    "Body={\"actions\":{\"name\":\"value\"}}" 
    LAST);

To address the dynamic name-value pair parameters that come into play, I had built a bufferthat would hold the Body string. I have used correlation and looping to achieve that. Code towards the end of building this buffer looks like this

lr_param_sprintf("s_buffer", "\\\"actions\\\":{%s}",paramStr);
lr_output_message("Final Actions string is %s", lr_eval_string("{s_buffer}"));

Output for above lr_output_message is

Final Actions string is \"actions\":{\"name\":\"value\"}

I replaced Body parameter in web_custom_request with the buffer I had built

web_custom_request("create", 
    "URL=someurl\create", 
    "Method=POST", 
    "Resource=0", 
    "RecContentType=application/json", 
    "Referer=someurl", 
    "Snapshot=t6.inf", 
    "Mode=HTML", 
    "EncType=application/json", 
    "Body={s_buffer}" 
    LAST);

I receive a HTTP Status-Code=400 (Bad Request) indicating the format of web_custom_request is wrong. I would highly appreciate if someone could help me with the Body parameter so that the web_custom_request embraces it like the way it should.

user1528884
  • 121
  • 1
  • 4
  • 13

1 Answers1

0

Record it three times. First two with the same login session. The third with another one. You likely have something that is going to change based upon data which is not being handled in the body appropriately.

James Pulley
  • 5,606
  • 1
  • 14
  • 14
  • Thanks for responding James. Body in 1st and 2nd recordings is "Body={\"actions\":{\"name1\":\"value1\"}}", and in 3rd is "Body={\"actions\":{\"name1\":\"value1\",\"name2\":\"value2\",\"name3\":\"value3\"}}", The buffer I had created has a string \"actions\":{\"MM-FM984-A\":\"15000\"}. I would need to encapsulate this value within flower braces{} and pass this value to Body. I replaced s_buffer with alue I printed from output and it worked fine. I suspect I'm passing a value "Body=\"actions\":{\"name1\":\"value1\",\"name2\":\"value2\",\"name3\":\"value3\"}", with my web_custom_request. – user1528884 Jul 16 '16 at 21:48