zohozoho-deluge

Zoho Creator Deluge InvokeUrl : How to pass form parameters to third party form?


How to pass form parameters to a third-party web form with Zoho-Creator-Deluge's InvokeUrl() function?

Here is the code I have tried:

Try-1

auth_url = "https://example-form.com"

header_data = Map();
header_data.put("Content-Type","multipart/form-data");

payload = Map();
payload.put("username",app.App_Username);
payload.put("password",app.App_Password);

response = invokeurl
[
    url :auth_url
    type :POST
    parameters:payload
    headers:header_data
    detailed: true
];

// debug
info response;

Try-2

auth_url = "https://example-form.com"

header_data = Map();
header_data.put("Content-Type","multipart/form-data");

payload = List();

username = {"paramName":"username","content":app.App_Username,"stringPart":"true"};
password = {"paramName":"password","content":app.App_Password,"stringPart":"true"};

payload.add(username);
payload.add(password);

response = invokeurl
[
    url :auth_url
    type :POST
    files :payload
    headers:header_data
    detailed: true
];

// debug
info response;

Both Try-1 and Try-2 result in the form-page being returned in response instead of the expected logged-in page. There isn't an error message, so it seems to be ignoring the parameters in payload.

Is there a different syntax that works?

Thanks


Solution

  • Okay I found the issue was that I needed to use the Content-Type of x-www-form-urlencoded in my request headers. Here is the Try-1 updated with the working Content-Type:

    
    header_data = Map();
    
    //------------------------------------------------------------------
    // This line is the fix!
    //------------------------------------------------------------------
    header_data.put("Content-Type","application/x-www-form-urlencoded");
    
    
    payload = Map();
    payload.put("username",app.App_Username);
    payload.put("password",app.App_Password);
    
    response = invokeurl
    [
        url :auth_url
        type :POST
        parameters:payload
        headers:header_data
        detailed: true
    ];
    
    // debug
    info response;