Service Virtualization

 View Only
Expand all | Collapse all

REST STEP - Attach/Upload file

  • 1.  REST STEP - Attach/Upload file

    Posted Nov 02, 2018 01:09 PM

    Please guide how to attach/upload file(pdf) through rest API step in automation test flow



  • 2.  Re: REST STEP - Attach/Upload file

    Broadcom Employee
    Posted Nov 02, 2018 02:45 PM

    What version of DevTest are you on?

    Are you wanting to upload the file to a browser URL?



  • 3.  Re: REST STEP - Attach/Upload file

    Posted Nov 05, 2018 04:38 PM

    Version 10.3

    We are using REST API(ZAPI REST URL) to attach reports to Jira # using zapi API..



  • 4.  Re: REST STEP - Attach/Upload file

    Broadcom Employee
    Posted Nov 06, 2018 10:05 AM

    DEVTEST has a Webservice Execution XML step, in which you can send an attachment as part of the request. You can do this in the Webservice Execution XML-->Attachments tab

    https://docops.ca.com/devtest-solutions/10-3/en/using/using-application-insight/creating-baselines/web-service-baselines/web-services-with-attachments

     

    Hope this helps.  



  • 5.  Re: REST STEP - Attach/Upload file

    Posted Nov 06, 2018 12:33 PM

    Hi Shiney, Thanks for the reply, I think that step is applicable only for SOAP request but In this case I will need to use REST API URL with attachment. The same working in postman but trying to find solution wiht Devtest



  • 6.  Re: REST STEP - Attach/Upload file

    Broadcom Employee
    Posted Nov 06, 2018 12:40 PM

    Yes you are right,  it is for Soap Requests.  



  • 7.  Re: REST STEP - Attach/Upload file

    Broadcom Employee
    Posted Nov 07, 2018 12:47 AM

    The Web Service Call step is primarily intended for SOAP request but the payload content is completely free for you to choose, so whether or not you put a Soap:Envelope in there is up to you, you can just as well put a JSON structure.

     

    One restriction it only does a POST. So, if your requirement is to do a POST to a REST API URL you can still use this step and its ability to attach a file.

     

    Cheers,

    Danny



  • 8.  Re: REST STEP - Attach/Upload file

    Posted Nov 08, 2018 01:28 PM

    Thanks Let me check



  • 9.  Re: REST STEP - Attach/Upload file
    Best Answer

    Broadcom Employee
    Posted Nov 06, 2018 12:56 PM

    Can you try this: 

     

    Add a MIME step,  
    Parameter : inventoryFile 
    File : {{filepath}} 
    MimeType:application/octet-stream 

     

    Then

    In the HTTP step : add the POST Parameter 
    inventoryFile {{fileName}} 

     



  • 10.  Re: REST STEP - Attach/Upload file

    Posted Nov 08, 2018 01:30 PM

    Thanks Shiney, will check and get back



  • 11.  Re: REST STEP - Attach/Upload file

    Posted Nov 08, 2018 01:44 PM

    Thanks Shiney, it worked able to post rest API with file attached



  • 12.  RE: Re: REST STEP - Attach/Upload file

    Posted Jun 24, 2022 10:55 AM
    Hi Shiney,

    We followed the suggested method as mentioned above but we are getting 400 bad request. Could you please suggest anything which we might be missing.

    Thanks,
    Priya


  • 13.  RE: Re: REST STEP - Attach/Upload file

    Posted Jun 28, 2022 12:27 AM
    Hi,

    Please try the options highlighted in below thread for sending attachments :
    https://community.broadcom.com/enterprisesoftware/question/how-to-send-form-data-in-a-rest-step-post-call

    Thanks

    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------