Image upload using rest api

Hi Katalon Team,

When I upload a image file through form data and some more fields my request is submitted successfully but when I get the response from getResponseText() the image file path is not uploaded correctly. when I generate same scenario in postman I get the response correctly. So I found this issue on katalon.

Please look into this problem urgently.

Thanks

1 Like

Please post screen shots of the issue.

here is the above screenshots.
image link is mentioned below after getting response from the server:

http://apps.nextdrive.deeccus.com:9596/dataset-images/43hrcl6gu79-c567dc73-4ffd-45ec-9c8e-422ccbbece5f/C:\\Users\\DAT-Asset-192\\Desktop\\api-image.jpg

Details:
Above screenshot is based on object repository.First api will take mobile no and country code then security code will generate.2nd api mobile no will be verified in 3rd api image will be uploaded.


when I use it through test case same problem occurs.Here is my code for image upload only:—

String endpoint = endpoint

String requestMethod=requestMethod

TestObjectProperty header1 = new TestObjectProperty(“Content-Type”, ConditionType.EQUALS, “multipart/form-data”)
//TestObjectProperty header2 = new TestObjectProperty(“Accept”, ConditionType.EQUALS, “application/json”)
ArrayList defaultHeaders = Arrays.asList(header1)

List body = new ArrayList()

FormDataBodyParameter first_name = new FormDataBodyParameter(“first_name”,first_name,“PARAM_TYPE_TEXT”)
FormDataBodyParameter last_name = new FormDataBodyParameter(“last_name”,last_name,“PARAM_TYPE_TEXT”)
FormDataBodyParameter email = new FormDataBodyParameter(“email”,email,“PARAM_TYPE_TEXT”)
FormDataBodyParameter password = new FormDataBodyParameter(“password”,password,“PARAM_TYPE_TEXT”)
FormDataBodyParameter country_code = new FormDataBodyParameter(“country_code”,country_code,“PARAM_TYPE_TEXT”)
FormDataBodyParameter mobile_number = new FormDataBodyParameter(“mobile_number”,mobile_number,“PARAM_TYPE_TEXT”)
FormDataBodyParameter device_type = new FormDataBodyParameter(“device_type”,device_type,“PARAM_TYPE_TEXT”)
FormDataBodyParameter os_ver = new FormDataBodyParameter(“os_ver”,os_ver,“PARAM_TYPE_TEXT”)
FormDataBodyParameter device_name = new FormDataBodyParameter(“device_name”,device_name,“PARAM_TYPE_TEXT”)
FormDataBodyParameter vendor_name = new FormDataBodyParameter(“vendor_name”,vendor_name,“PARAM_TYPE_TEXT”)
FormDataBodyParameter image = new FormDataBodyParameter(“image”,image,“File”)

body.add(first_name)
body.add(last_name)
body.add(email)
body.add(password)
body.add(country_code)
body.add(mobile_number)
body.add(device_type)
body.add(os_ver)
body.add(device_name)
body.add(vendor_name)
body.add(image)

HttpFormDataBodyContent bodyContent = new HttpFormDataBodyContent(body)

RequestObject ro1 = new RequestObject()

ro1.setRestUrl(endpoint)

ro1.setHttpHeaderProperties(defaultHeaders)

ro1.setRestRequestMethod(‘POST’)

ro1.setBodyContent(bodyContent)

ResponseObject respObj1 = WS.sendRequest(ro1)

println(respObj1.getResponseText())

//Verifing STATUS-CODE
code1 = respObj1.statusCode
//println(code)

And I have used the datadriven method for the above code.

I have also attached the postman screen here.
![Screenshot_4|690x326](upload://yk![Screenshot_2|690x427]

Any update about the above issue from katalon Team???

Any Update team.I have still not find the solution?

Hi @nazneen, Can you post the screenshot in Postman too?

Hi,

Here is the postman link:

Screenshot by Lightshot.

and here is the image link:

I have noticed that using katalon image is not posted on server.Please look into this matter. Its very urgent.

Thanks,

Please help me on this.It creates serious issues on our development end. If this will not work then sadly We have to stop using katalon . :frowning: Please please urgent help.

Hi @nazneen,
Can you share the endpoint?

Hi,

Yes. there is 3 process for registration process.
for 1st) country-code and mobile no taking

for 2nd country code mobile no and security code is taking

for 3rd step user details is taking like first name, last name, image and so on…

here is the end point for the 3 of the above.

http://apps.nextdrive.deeccus.com:9596/apps/rider/api/10000-registration-step1
json:
{
“country_code”: “91”,
“mobile_number”: “8116703641”

}
http://apps.nextdrive.deeccus.com:9596/apps/rider/api/10010-registration-step2
{
“country_code”: “91”,
“mobile_number”: “8116703641”,
“security_code”: “737713”
}
http://apps.nextdrive.deeccus.com:9596/apps/driver/api/10640-driver-registration-step3

http://prntscr.com/nuqwo9.

everything is working fine except the image file.

Thanks

any update plz?

Hi katalon team,

I am still waiting.Is there any way to solve out this problem ? Please help.

Hi @nazneen,
I cannot access your endpoints

Hello huynguyen,

Image upload problem is very common. I am not able to upload any type of image file through manual katalon. Also If the image is uploaded either its showing wrong path or shwoing 404 error path. i found this is very common problem while uploading image. you can check it with other api too which has image upload features.

I found this is as a bug in katalon.

Hi @nazneen,
Can you send me the HAR file logged when you execute your test case?

hars-7169482642559532904.zip (201.5 KB)

Hi Huynguyen,

Here is the list of har file.
I also found several related issues on forum but not found any solution related to this. please guide on the above.
Thanks

Hi @nazneen,
From the HAR files, I can see that your requests have been sent successfully. Have you checked the returned url of the image to see if the image has been uploaded successfully?

No the image is not uploaded successfully. when I clicked on that image url, it shows me 404 error message.

Here is the Screenshots

and here is the image url:

http://apps.dev.fdv2.com/dataset-files/5je09lei8r-0ea7773d-61e6-43fa-b966-323a9138ddf8/C:\\Users\\DAPL-Asset-180\\Desktop\\api-image.jpg

I think the image format is not taking correctly.

any Update Huynguyen?