Search code examples
flurlprocessmaker

Flurl post data


I have a processmaker web entry form and want to post data to it.
request should be like this
enter image description here
My code is like this:

var ticket = "https://xxx.yyyy.zzz"
            .AppendPathSegment("/sysworkflow/en/neoclassic/3498535156074b324397243068854136/8211975096074b37b513794064716441Post.php")
            .PostJsonAsync(new
            {
                form = new
                {
                    contract_expert = "xxxxx",
                    vendor_id = "1111",
                    vendor_name = "aaa",
                    contract_number = "bbB",
                    contract_title = "ccc"
                }
            })
            .ReceiveString().Result;

The problem is when I call this data with postman data will sit in their place but with flurl everything is empty after submit data. btw postman content-type is multipart/form-data


Solution

  • multipart/form-data != JSON, so don't use PostJsonAsync. Use PostMultipartAsync. This is documented here. Here's the relevant change to what you have:

    .PostMultipartAsync(mp => mp.AddStringParts(new
    {
        contract_expert = "xxxxx",
        vendor_id = "1111",
        vendor_name = "aaa",
        contract_number = "bbB",
        contract_title = "ccc"
    }))