This is how im posting data . a json string and content in stream or bytes.
Verifying the content length looks like the stream im passing is not reaching or not being read.
Can someone help me.
data/Content is not a valid input to pub.client:http.
data/string is used when you want to pass the string exactly as is – jsonString in isolation is likely not the content you want to be sending via multipart form. Indeed, I’m curious as to why JSON would be a value within a field of the form. Seems odd.
As @DINESH_J implies, there are a number of steps to follow to create a proper multipart form. Refer to the services in the MIME folder and the docs for how to use them to create and send a multipart form.
But still the attachment content is not going. Facing error like Content is required.
Is there any sample code for this i need to send pdf as an attachment stream or bytes.
Do not call streamToString. That is the issue Not only is it unnecessary, it is wrong – the stream does not contain a string. It has multiple types of data, including the binary PDF. When you call streamToString, the PDF content is essentially made useless. Just pass the stream from getEnvelopeStream as data/mimeStream. Nothing else needs to be passed in the data doc.
When calling createMimeData, set the subType input to form-data. If you don’t do that, the Content-Type gets set to multipart/mixed, as shown in the MIME data you shared. You do not need to set any headers in the http call. When calling http with the mimeStream the headers from that are appended to the http headers (as described in the service documentation).
Why is there a jsonString being mapped to data/string? Based upon what you shared for the MIME steps there is no JSON content involved.
Follow the documentation. Don’t rely solely on trial-and-error to figure out what to do – which can be misleading as when you tried to pass “Content” as an input to http but that is not the way to do this.
I would strongly encourage you to split the MIME data creation into its own service. That way you can run it, test it, tweak it, call it from another service to review what was created, etc. without posting it to the target.
And you can compare, to some degree, what you’re creating with your steps with the console output you see in Postman. So you can see what adjustments to make to match what Postman does behind the scenes.