Parameters in multipart/form data in pub.client:http

Hello,

I need to insert 2 parameters with multipart/form-data in pub.client:http. I already put content-type: multipart/form-data in headers and put the parameters inside args, but it didn't work. Anyone knows how to pass 2 parameters multipart/form-data in pub.client:http ???

Hi Sabrina,
You can the parameters as data in any format i.e. String, bytes or stream.

What is the error you are seeing?

image

Regards,
Praba.

Are you sure you need to use multipart/form-data? Per the documentation,

When you submit data using args , Integration
Server automatically sets the value of the Content-
Type header to application/x-www-formurlencoded.

This sends the parameters as a query string in the URL for the GET method and in the HTTP body for the POST method. This should be sufficient for typical text arguments.

The doc continues:

If you want to explicitly specify a different Content-
Type value, you must submit the value using the
string or bytes variable.

The reason to use multipart/form-data is if the data of one or more of the fields contains lots of non-text data. To use that Content-Type, you’ll need to do more work to create the payload yourself with the pub.mime services.

Do the 2 fields contain simple text values? If so, use the application/x-www-formurlencoded approach. If not, review the pub.mime services.

Hi Shabrina,
As @ reamon mentioned, you need to use pub.mime services to create a mime object with multiple parts (attachments) and then use to send that stream in the pub.client:http.

This thread How to send a mimestream using pub.client:http - Forum - Software AG Tech Community & Forums might be useful for you.

Thanks

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.