Apickli-Sending files as form parameters in the request

Does Apickli framework support sending files in the form parameters as part of the request body? An example would be appreciated.

I don't want to send the contents of a file rather I want to send the file directly to the backend.

The API takes 2 files(.xml and .txt) in the request and responds with JSON data.

0 6 610
6 REPLIES 6

Not applicable

you can use @file in the curl with proper content type.


curl --location --request POST 'https://**************-prod.apigee.net/testimage' \
--header 'Content-Type: image/jpeg' \
--data-binary '@/C:/Users/*****/Desktop/Capture11.JPG'

Thanks for reaching out Priyadarshi. Well, I need it for the purpose of BDD testing where I could not use the curl commands.

in postman you can have the option to add the file but only binary has the option to add the file and it will add the content type with reference to file type.

I know this option in the postman.But I am trying to do BDD testing using apickli integration testing framework.

Hi @Arun Prasath Sivanesan

You said "I don't want to send the contents of a file rather I want to send the file directly to the backend." - can you elaborate on this a little please? If you don't want to send the file contents, what exactly do you want to send? Filename?

Let me make it clear. I want to send the files which have the content. I don't want to directly send the contents(plz refer to the second curl).

this is how my curl looks for the happy path

curl --location --request POST 'https://xxxx.apigee.net/v1/xxxx-func/converttojson --header 'contentType: multipart/form-data; boundary=<calculated when request is sent>' \ --header 'Authorization: Bearer xxxxxxxx' \ --form 'schema=@/C:/Users/yayz/Downloads/product.txt' \ --form 'data=@/C:/Users/yayz/Downloads/O_SP_Product.XML' \ --form 'ContentType=multipart/form-data; boundary=<calculated when request is sent>'

I dont want to do the following.

curl --location --request POST 'https://xxxx.apigee.net/v1/xxx-func/converttojson' \ --header 'contentType: multipart/form-data; boundary=<calculated when request is sent>' \ --header 'Authorization: Bearer xxxxxxxxx' \ --form 'schema=<bookstore><book>" + "<title>Everyday Italian</title>" + "<author>Giada De Laurentiis</author>" + "<year>2005</year>" + "</book></bookstore>' \ --form 'data=Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry'\''s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. ' \ --form 'ContentType=multipart/form-data; boundary=<calculated when request is sent>'

The above two curls are for understanding purposes. I am trying to do integration testing using cucumber and apickli from Intellij IDE.

Please let me know if you have any more questions.