Hello
I would like to adapt this curl request to Gatling
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
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
Thanks for the info
I modified to formUpload but get the same results from the server
BadRequestError: Invalid JSON in the operation multipart field
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)
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 ?
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
Also, you can try logging that string to the console to make sure that it actually is valid json/graphql query.
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.