webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  How to send a multipart form-data request in webMethods using pub.mime?

    Posted Wed June 07, 2023 01:23 PM

    Product: webMethods . io Integration version: 10.16.1.0

    Question: How to send a multipart form-data request in webMethods HTTP Request (pub.client:http).

    For instance, in Python this can be done like this

    import requests
    url = 'https://app.test.com/test/api/v1/webhook/12345
    headers = {
    'Authorization': 'Bearer 12345'
    }
    files = {
    'file': ('TEST.csv', open(r'C:\Users\ME\Desktop\TEST.csv', 'rb')),
    'FileName': 'TEST'
    }
    response = requests.post(url, headers=headers, files=files)
    

    In Postman it can be done by selecting “form-data” as the payload type and entering the key “file” with a value of the uploaded CSV file and another key “FileName” with a value of the name of the file.

    I have followed the other answers (i.e. How to send a mimestream using pub.client:http - #6 by Martin_Gawantka) but they do not specify how to attach the “file” and “FileName” expected keys with respective values. Same issues on webMethods.io cloud and webMethods on-prem. I understand we must use pub.mime to complete this but I would like to know more about adding the headers.


    #webMethods-io-Integration
    #webMethods
    #webMethods-cloud


  • 2.  RE: How to send a multipart form-data request in webMethods using pub.mime?

    Posted Mon June 12, 2023 08:23 AM

    Hi @GMook ,
    I have created the sample to handle the mime data on webmethods.io Integration.
    Created the flow service how you can submit the mime data using Http request.
    For testing purpose I am using azure storage to get the stream data and.

    Attaching the sample for same.
    SubmitCSVMimeData.zip (10.7 KB)

    Let me know if this helps.

    Regards
    Vikash Sharma


    #webMethods-cloud
    #webMethods-io-Integration
    #webMethods


  • 3.  RE: How to send a multipart form-data request in webMethods using pub.mime?

    Posted Mon June 12, 2023 07:52 PM

    Thanks for the reply,

    Unfortunately, the sample Service provided titled SubmitCSVMimeData used a “Content-Type” header of “multipart/form-data”. However, the way we built out the integration in the call it does not accept that giving a error message of

    MIME part of type “multipart/form-data” contains object of type java.io.ByteArrayInputStream instead of MimeMultipart

    When trying to use Content-Type of text/csv the endpoint gives a status code of 415 for Unsupported Media Type. The Content-Type of application/json gives status code of 400 for Bad Request.

    For the “Content-Disposition ” header I was told to do form-data; name=“file”; filename=“CSVDataSample.csv”. However, I do not exactly see how that matches the required key-value headers of the key “file” having a value of the actual file contents and then the key “FileName” having the name of the file itself.

    The documentation from SoftwareAG on MIME messages does not cover this use case provided by the Postman Proof Of Concept attached above in the original message.

    Look forward for more information to hopefully get this resolved asap.

    Thank you,
    Garret


    #webMethods-cloud
    #webMethods
    #webMethods-io-Integration


  • 4.  RE: How to send a multipart form-data request in webMethods using pub.mime?

    Posted Tue June 13, 2023 12:59 AM

    hi @GMook ,
    Can you please share the service you are trying .
    We can look into it.

    Regards
    Vikash Sharma


    #webMethods-io-Integration
    #webMethods-cloud
    #webMethods


  • 5.  RE: How to send a multipart form-data request in webMethods using pub.mime?

    Posted Wed June 28, 2023 12:20 AM

    hi @GMook,
    We resolved the issue by using the workflow.

    Regards
    Vikash Sharma


    #webMethods-io-Integration
    #webMethods
    #webMethods-cloud


  • 6.  RE: How to send a multipart form-data request in webMethods using pub.mime?

    Posted Wed November 29, 2023 03:54 AM

    hi Garret/Vikash,

    Hope you are doing good . I am also facing the similar issue in webMethods.io and my requirement is to send to CSV data through HTPP post. Let me know if you have found the solution

    If i set the Content-Type field in mimeHeader as text/csv the endpoint gives a status code of 415 for Unsupported and If i set the content-type in mimeHeader as multipart/form-data the below error is received
    error received : MIME part of type “multipart/form-data” contains object of type java.io.ByteArrayInputStream instead of MimeMultipart.

    Pls note that , the implementation is done as below

    • Initialize the mime header
    • Mime CreateMimeData
    • Convert the CSV string into stream through StringToStream service
    • Mime AddBodyPart
    • MIme GetEnvelopStream

    Thanks
    Sunil


    #webMethods-cloud
    #webMethods-io-Integration
    #webMethods


  • 7.  RE: How to send a multipart form-data request in webMethods using pub.mime?

    Posted Thu November 30, 2023 02:02 AM

    hi @Sunil_Salian ,
    Can you please refer to this article for same.

    Let me know if you face any difficulty.

    Regards
    Vikash Sharma


    #webMethods-io-Integration
    #webMethods
    #webMethods-cloud


  • 8.  RE: How to send a multipart form-data request in webMethods using pub.mime?

    Posted Thu November 30, 2023 02:46 AM

    hi Vikash,

    I have referred the approach and still facing the issue . So planning to write the csv file into directory (home/sagadmin/flow/user_data) workflow and do the HTTP post instead of mime approach . So could you please let me is there any file size limitation if we write the file into home/sagadmin/flow/user_data?

    Thanks
    Sunil


    #webMethods-cloud
    #webMethods
    #webMethods-io-Integration


  • 9.  RE: How to send a multipart form-data request in webMethods using pub.mime?

    Posted Thu November 30, 2023 05:26 AM

    Hi Sunil,
    I am not sure why it is not working.
    Anyways when you are submitting the request from flow service to workflow.
    In the workflow we can submit max up to 10 mb data.

    Regards
    Vikash Sharma


    #webMethods-io-Integration
    #webMethods-cloud
    #webMethods