Forum Discussion

mchiang's avatar
mchiang
New Contributor
8 years ago
Solved

Convert curl request to SoapUI Request

I'm currently trying to convert a working curl command to a valid SoapUI test case but am having some issues. I am trying to attach a json file and the server also requires authorisation. I'm able to configure the authorisation correctly but when comparing the raw packet of both curl and SoapUI, it seems that SoapUI seems to be adding this to the header: 

 

Content-Type: application/json; name="file"

 

where as the curl request has:

Content-Type: application/json

 

 Is there a way to edit this part of the header? 

 

Alternatively is another way to make this work?

 

EDIT: just a bit more info about my test case. To replicate the curl request, I have added the attachment and checked the 'Cached' box. I have seen other questions which say that the 'Name' field should be the full path (C:/etc/etc) and others that do not specify this. I have tried both to no avail. 'Content type' is set to application/json as this is what comes up in the curl request and the 'ContentID' = attachment. I have then added a parameter with the 'Name' = attachment, 'Value' = file:*filename* (without the path), 'Style' = QUERY and 'Level' = RESOURCE. 'Media Type is multipart/form-data, 'PostQueryString' box is checked as well and 'Method' set to POST.

  • The workaround to perform is to remove the name via Groovy.  You can change it by using the below Groovy script in event handler FilterRequest.filterRequest:

     

    def bodyPart1 = context.getProperty("httpMethod").requestEntity.message.content.getBodyPart(0)

     

    bodyPart1.removeHeader("Content-Type")

    bodyPart1.addHeader("Content-Type","application/json")

4 Replies

    • mchiang's avatar
      mchiang
      New Contributor

      Hi nmroa

       

      I'm currently using version 1.9.0. Unfortunately, I don't have a WSDL file so I cannot do it that way. I have also looks through that documentation and didn't find anything helpful.

      • nmrao's avatar
        nmrao
        Champion Level 3

        That was a typo, it is wadl not wsdl if you are using a REST API.

         

        wadl / swagger definition is something similar to wsdl for SOAP, acts a contract between the different parties who interact.

         

        Otherwise, you have to add the artifacts manually which may be tedious if you many methods in the API.

         

        You can have a look this video to get an idea

        https://www.youtube.com/watch?v=L2SMZ9bbDvE