0

with the function:

web_reg_save_param("questionId", "LB=secretKnowledges\":\\[\\{", "RB=\"", LAST);

I try to catch the value of the "questionId" parameter which comes from the server response as a (json file) and looks so:

"salutation":{"firstNaAction me":"Sebastian","lastName":"Martens"},"userAccount":{"mail":"gcdmtest_bp_pr_acc_po_20073@trash-mail.com","notificationLevel":"NEW_DEVICE","authenticationLevel":"ONE_FACTOR","gcid":"bb2e64a9-1b39-4692-9c52-4845eb15c4f7","secretKnowledges":[{"questionId":11301},{"questionId":11302}],"secretKnowledgeActivated":true,"status":"ACTIVATED"}}

instead of I got the following error:

Action.c(23): Error -26377: No match found for the requested parameter "questionId". Either the specified boundaries were not found in the response or the matched text is longer than current max html parameter size of 8000 bytes. The total length of the response is 1506 bytes. You can use web_set_max_html_param_len to increase the max parameter size.    [MsgId: MERR-26377]Action.c(23): Notify: Saving Parameter "questionId = ".

what did I do wrong?

otmann
  • 37
  • 2
  • 17

1 Answers1

1

Not sure if I understand you. If you need values of all questionId parameters in the response, try the following:

web_reg_save_param("questionId", "LB={\"questionId\":", "RB=}", "Ord=All", LAST);

This will produce an array of parameters questionId_1, questionId_2 etc. Also the number of parameters will be saved to questionId_count parameter. But if you need just the first occurrence of that parameter, just skip the Ord=All argument.

There's also a special extraction API for JSON responses: web_reg_save_param_json. Here's an example for your case:

web_reg_save_param_json("ParamName=questionId", "QueryString=$..questionId",
   "SelectAll=Yes", LAST);

Also if you need a RegEx-based parameter extraction, you could try web_reg_save_param_regexp.

tserg42
  • 322
  • 3
  • 8
  • @teserg: thank you it did work, but can you explain me the logic behind this expression: `LB={\"questionId\":", "RB=}`, because you set both boundaries under curly bracket, and the the ""questionId" in the response is set under square bracket. I mean you did not devaluate it why? – otmann Oct 12 '15 at 07:46
  • `web_reg_save_param` is nothing more that a text parsing function. It just tries to find the Left Boundary (LB), then tries to find the Right Boundary after the position of LB. If both are found, it extracts any text between them. – tserg42 Oct 12 '15 at 20:40
  • @otmann if any of the answers has solved your question, please consider accepting it by clicking the check-mark. This is not obligatory :). – tserg42 Mar 23 '16 at 12:15