# Adapt Curl request

**URL:** <https://community.gatling.io/t/adapt-curl-request/5671>\
**Category:** Gatling (Open-Source)\
**Created:** [June 17, 2020, 7:28am UTC](https://community.gatling.io/t/adapt-curl-request/5671 "2020-06-17T07:28:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![El\_Barto](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@El\_Barto](https://community.gatling.io/u/El_Barto)\
**Post date:** [June 17, 2020, 7:28am UTC](https://community.gatling.io/t/adapt-curl-request/5671/1 "2020-06-17T07:28:14Z")

</div>

Hello

I would like to adapt this curl request to Gatling

```auto
curl localhost:3001/graphql \
  -F operations='{ "query": "mutation ($image: Upload!) { singleUpload(image: $image) { id } }", "variables": { "image": null } }' \
  -F map='{ "0": ["variables.file"] }' \
  -F 0=@a.txt

I tried this way but it is not accept from the server: I get : Error: "Multipart: Boundary not found"
Image001.jpg is avalaible in the "resources" folder of Gatling
The curl request works properly even from postman ou Insomnia

 exec(http("Upload")
.post("${env}/graphql")
.headers(Map("Content-Type" -> "multipart/form-data"))
.formParam("operations","{ \"query\": \"mutation ($image: Upload!) { singleUpload(image: $image) { id } }\", \"variables\": { \"image\": null } }")
.formParam("map","\"{ \"0\": [\"variables.image\"] }\"")
.formParam("0", "\"@image001.jpg\"")

Any idea ?

Thanks in advance

Thanks in advance

```

---

<div class="post-metadata">

**Author:** ![El\_Barto](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@El\_Barto](https://community.gatling.io/u/El_Barto)\
**Post date:** [July 1, 2020, 2:00pm UTC](https://community.gatling.io/t/adapt-curl-request/5671/2 "2020-07-01T14:00:49Z")

</div>

Hello

Any idea ?

Or there is a way to use gatling recorder to record on Postman ?

It will be great to have some help Stephane maybe 🙂

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [July 1, 2020, 2:43pm UTC](https://community.gatling.io/t/adapt-curl-request/5671/3 "2020-07-01T14:43:24Z")

</div>

formParam is for String values.  
formUpload is for file.  
[https://gatling.io/docs/current/http/http\_request/#multipart-form](https://gatling.io/docs/current/http/http_request/#multipart-form)

---

<div class="post-metadata">

**Author:** ![El\_Barto](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@El\_Barto](https://community.gatling.io/u/El_Barto)\
**Post date:** [July 1, 2020, 2:58pm UTC](https://community.gatling.io/t/adapt-curl-request/5671/4 "2020-07-01T14:58:09Z")

</div>

Thanks for the info

I modified to formUpload but get the same results from the server

BadRequestError: Invalid JSON in the operation multipart field

---

<div class="post-metadata">

**Author:** ![El\_Barto](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@El\_Barto](https://community.gatling.io/u/El_Barto)\
**Post date:** [July 1, 2020, 3:04pm UTC](https://community.gatling.io/t/adapt-curl-request/5671/5 "2020-07-01T15:04:32Z")

</div>

Thanks for the info  
I updated to formUpload

exec(http(“Upload”)

.post("${env}/graphql")  
.headers(Map(“Content-Type” → “multipart/form-data”))  
.formParam(“operations”, “{ “query”: “mutation ($image: Upload!) { singleUpload(image: $image) { id } }”, “variables”: { “image”: null } }”)  
.formParam(“map”, “{ “0”: [“variables.image”] }”)

.formUpload(“0”, “image001.jpg”)

But still get the same error from the server

BadRequestError: Invalid JSON in theoperation multipart field ([https://github.com/jaydenseric/graphql-multipart-request-spec](https://github.com/jaydenseric/graphql-multipart-request-spec))

---

<div class="post-metadata">

**Author:** ![El\_Barto](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@El\_Barto](https://community.gatling.io/u/El_Barto)\
**Post date:** [July 1, 2020, 3:13pm UTC](https://community.gatling.io/t/adapt-curl-request/5671/6 "2020-07-01T15:13:53Z")

</div>

If i can add

From the log, the request send by Gatling is like this :

HTTP request:  
POST ${env}/graphql  
headers=  
accept: _/_  
host: ${env}  
content-type: multipart/form-data; boundary=  
content-length: 281666

multipartBody=  
StringPart: name=operations contentType=null dispositionType=null charset=UTF-8 transferEncoding=null contentId=null  
StringPart: name=map contentType=null dispositionType=null charset=UTF-8 transferEncoding=null contentId=null  
ByteArrayPart: name=0 contentType=image/jpeg dispositionType=null charset=null transferEncoding=null contentId=null filename= image001.jpg

i don’t think it suppose to be like that ?

---

<div class="post-metadata">

**Author:** ![Lance\_Reed](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@Lance\_Reed](https://community.gatling.io/u/Lance_Reed)\
**Post date:** [July 1, 2020, 3:21pm UTC](https://community.gatling.io/t/adapt-curl-request/5671/7 "2020-07-01T15:21:34Z")

</div>

I think your grapql query is the issue.

Correct me if I’m wrong, but $image here goes with the query, not the Gatling EL or Scala. So, maybe you can try $image there instead of $image to avoid interpretation issues.

[https://gatling.io/docs/current/session/expression\_el](https://gatling.io/docs/current/session/expression_el)

Also, you can try logging that string to the console to make sure that it actually is valid json/graphql query.

---

<div class="post-metadata">

**Author:** ![El\_Barto](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@El\_Barto](https://community.gatling.io/u/El_Barto)\
**Post date:** [July 1, 2020, 3:33pm UTC](https://community.gatling.io/t/adapt-curl-request/5671/8 "2020-07-01T15:33:39Z")

</div>

Hi Lance  
Thanks for your time  
I did try with $image but instead of $image i used $$image because it was consider as invalid escape character

But same results. ☹
