# How to write a request with form-data using Robotframework

**URL:** <https://forum.robotframework.org/t/how-to-write-a-request-with-form-data-using-robotframework/8925>\
**Category:** Robot Framework\
**Created:** [31 May 2025 14:45 UTC](https://forum.robotframework.org/t/how-to-write-a-request-with-form-data-using-robotframework/8925 "2025-05-31T14:45:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fatimafe](https://avatars.discourse-cdn.com/v4/letter/f/c77e96/32.png) [@Fatimafe](https://forum.robotframework.org/u/Fatimafe)\
**Post date:** [31 May 2025 14:45 UTC](https://forum.robotframework.org/t/how-to-write-a-request-with-form-data-using-robotframework/8925/1 "2025-05-31T14:45:26Z")

</div>

hi please help me for this curl:  
curl -X POST   
[http://10.100.8.22:12000/PodMedad/UploadFile](http://10.100.8.22:12000/PodMedad/UploadFile)   
-H ‘Accept-Language: fa-IR’   
-H ‘Accept-Version: 7’   
-H ‘Postman-Token: a3bbb1bb-e20a-484b-8985-60df8963679e’   
-H ‘cache-control: no-cache’   
-F ‘File=@C:\Users\Desktop\download.jpg’   
-F Output=file

i try this but i have error in file:  
\*\*\* Variable \*\*\*  
${UploadFileUrl} /PodMedad/UploadFile  
${file\_path} D:\repo\repo\download.jpg

Success UploadFile Result  
${file\_data}= Get Binary File ${file\_path}  
${fileDir} ${fileName}= Split Path ${file\_path}  
${partData1}= Create List ${fileName} ${file\_data} download.jpg  
Send MultiPart Post Request V.7 without body ${UploadFileUrl} ${file\_data}

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [31 May 2025 16:13 UTC](https://forum.robotframework.org/t/how-to-write-a-request-with-form-data-using-robotframework/8925/2 "2025-05-31T16:13:46Z")

</div>

Hi Fatima,

> [@Fatimafe](#):
>
> Send MultiPart Post Request V.7 without body

Well the contents of this keyword and the error message are both missing from, and quite relevant to your question. Without that information we can’t even guess what the problem might be?

I will also comment about windows paths and the use of a single `\` :

> [@Fatimafe](#):
>
> \*\*\* Variable \*\*\*  
> ${UploadFileUrl} /PodMedad/UploadFile  
> ${file\_path} D:\repo\repo\download.jpg

Reading and understanding [Escaping](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#escaping) is a good idea, the builtin `${/}` variable is also handy.

Dave.

---

<div class="post-metadata">

**Author:** ![Fatimafe](https://avatars.discourse-cdn.com/v4/letter/f/c77e96/32.png) [@Fatimafe](https://forum.robotframework.org/u/Fatimafe)\
**Post date:** [1 June 2025 05:12 UTC](https://forum.robotframework.org/t/how-to-write-a-request-with-form-data-using-robotframework/8925/3 "2025-06-01T05:12:37Z")

</div>

Dear dave please suggest a correct test case for this curl request:  
curl -X POST  
[http://10.100.8.22:12000/PodMedad/UploadFile](http://10.100.8.22:12000/PodMedad/UploadFile)  
-H ‘Accept-Language: fa-IR’  
-H ‘Accept-Version: 7’  
-H ‘Postman-Token: a3bbb1bb-e20a-484b-8985-60df8963679e’  
-H ‘cache-control: no-cache’  
-F ‘File=@C:\Users\Desktop\download.jpg’  
-F Output=file

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [1 June 2025 07:32 UTC](https://forum.robotframework.org/t/how-to-write-a-request-with-form-data-using-robotframework/8925/4 "2025-06-01T07:32:27Z")

</div>

Hi Fatima,

If it were me I’d probably use [Create Session](https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html#Create%20Session) in my suite setup and then use [POST On Session](https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html#POST%20On%20Session) to actually upload the file because you are probably going to need to test more api calls than just this one?

But if this is the only API call you need to make then you could just use [POST](https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html#POST).

Either way, you’ll need to set up the header (`-H`) and request body (`-F`) values ([Create Dictionary](https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Create%20Dictionary) is useful for this). And it’s worth noting that the details of what the post requests are expecting is documented in [GET](https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html#GET).

There are examples on this forum for similar file uploads with Requests Library, so search for them and use them as examples.

Dave.

---

<div class="post-metadata">

**Author:** ![Fatimafe](https://avatars.discourse-cdn.com/v4/letter/f/c77e96/32.png) [@Fatimafe](https://forum.robotframework.org/u/Fatimafe)\
**Post date:** [1 June 2025 08:39 UTC](https://forum.robotframework.org/t/how-to-write-a-request-with-form-data-using-robotframework/8925/5 "2025-06-01T08:39:40Z")

</div>

can you help me about this request body with keyword Create dictionay:  
-F ‘File=@C:\Users\Desktop\download.jpg’  
-F Output=file  
i need more help

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [2 June 2025 10:51 UTC](https://forum.robotframework.org/t/how-to-write-a-request-with-form-data-using-robotframework/8925/6 "2025-06-02T10:51:58Z")

</div>

Hi Fatima,

The way to upload the file seems to vary from app to app, and it’s not something I’ve done myself, but there are examples on the forum of people who’ve succeeded, I’ll give you a few links to look at:

- [Uploading files with auth](https://forum.robotframework.org/t/uploading-files-with-auth/6850)
- [I am getting error 400 on automating POST API with file upload(string($binary))ad(](https://forum.robotframework.org/t/i-am-getting-error-400-on-automating-post-api-with-file-upload-string-binary-ad/6182)
- [Facing Issue with testing File Upload API using robot framework](https://forum.robotframework.org/t/facing-issue-with-testing-file-upload-api-using-robot-framework/254)

Hopefully one of those will help you.

Dave.
