Ankündigung

Einklappen
Keine Ankündigung bisher.

ajaxVTL Parameters not working (Problem with Encode)

Einklappen
X

ajaxVTL Parameters not working (Problem with Encode)

Einklappen
  • Filter
  • Zeit
Alles löschen
neue Beiträge

  • ajaxVTL Parameters not working (Problem with Encode)

    I'm trying to make a call to a vm file that will save and return the status message but I have some issues with the parameters.

    I'm receiving this error message, looks like I have to encode it, but even when I encode it doesn't work.

    de.uplanet.lucy.server.servlet.BadRequestIxServlet Exception: Cannot hex-decode rq_quantity=420.

    This is my js code.

    Code:
    function reOrder(sku, quantity){
    console.log("entro");
    ## console.log(quantity);
    ## console.log(qq);
    ajaxVTL("internal/system/vm/html/odata/test.vm", {
    dataType: "json",
    method: "post",
    data: {
    "rq_sku": sku,
    "rq_quantity": quantity,
    "rq_ag": "${Session.get('sessionCARTKUNNR')}",
    "rq_fullsales": "${Session.get('sessionSALESORG')}",
    "rq_cartcatalogue": "${Session.get('sessionCARTCATALOGUE')}",
    "rq_userId": "${User.getId()}",
    "rq_isCS": "${Session.get('isCustomerService')}",
    "rq_isSR": "${Session.get('isSalesRep')}",
    "rq_sessionId": "${Session.getId()}"
    }
    }).done(function (data) {
    console.log("entro2");
    console.log(data);
    if (data.loginStatus === "success") {
    
    }
    });
    }
    And this is my very simple vm code:

    Code:
    $Response.setIgnoreWrite(true)
    ## build json-response
    #set($answer = $CollectionFactory.createMap())
    
    #if($Request.containsKey("rq_sku"))
    $answer.put("sku", $!Request.get("rq_sku"))
    #end
    
    #if($Request.containsKey("rq_quantity"))
    $answer.put("quantiti", $!Request.get("rq_quantity"))
    #end
    
    $Response.setHeader("Cache-Control", "no-store")
    $Response.setHeader("Content-Type", "application/json; charset=UTF-8")
    $Response.setIgnoreWrite(false)
    
    $JSON.toJSONString($answer)
    This is how I encode it.

    Code:
    #set($strSkuHash = $!Codec.hexEncodeString("$!sku", "UTF-8") )
    #set($strSkuHash2 = $!Codec.hexEncodeString("$!row[4]", "UTF-8") )
    <button class="button" onclick='reOrder($strSkuHash, $strSkuHash2);'>Reorder</button>
    I couldn't find any documentation how this works, and how data should be encoded and why my quantity brokes all the time, but the sku variable works.

    I got this the values encoded, the second that is the quantity just fails and if I don't encode it, it says throws the error "Cannot hex-decode"

    Code:
    reOrder(313233323835, 3432302E303030)
    Any ideas how should I proceed and how the encoding works?

    Regards!

  • #2
    If you are using request-Parameters with the Prefix "rq_", the Intrexx Business Logic will try to hex-decode them.
    So in order for it to work you need to hex-encode them before sending.

    Or simply use another Prefix, other than "rq_"

    Kommentar


    • #3
      I changed the "rq_" prefix and now is working.
      Thanks!

      Kommentar

      Lädt...
      X