Error when using __FileToString to set GraphQL request body
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 5
Description
**Mateus Dadalto** ([Bug 66122](https://bz.apache.org/bugzilla//show_bug.cgi?id=66122&redirect=false)):
I'm trying to set my body based on what is in a file and it fails saying the JSON is invalid. But when I set the request body manually the same content the request works. In the results tree view I can see that the only difference is that the manual request is "encoded", it has /n instead of visual newlines.
Steps to reproduce:
-1: Download and open the .jmx attached to this bug
-2: Create a file with the content being the body from the first request ("With Body Set Manually")
-3: change the path on the second request ("With Body From File") to your file path
-4: Run and see in the View Results Tree that the first one works and the second one fails
Created attachment [Jmeter%20GraphQl%20Bug.jmx](https://apache.github.io/jmeter-bugzilla-attachments/22/66122/38317/Jmeter%2520GraphQl%2520Bug.jmx): A sample project to reproduce the bug
Jmeter%20GraphQl%20Bug.jmx
````xml
false
true
false
continue
false
1
1
1
false
true
Content-Type
application/json
false
{"operationName":null,"query":"query {\n allFilms {\n films {\n title\n director\n releaseDate\n speciesConnection {\n species {\n name\n classification\n homeworld {\n name\n }\n }\n }\n }\n }\n}"}
=
true
swapi-graphql.netlify.app
https
.netlify/functions/index
POST
false
false
true
false
query {
allFilms {
films {
title
director
releaseDate
speciesConnection {
species {
name
classification
homeworld {
name
}
}
}
}
}
}
true
false
{"operationName":null,"query":"${__FileToString(your-file-path,,)}"}
=
true
swapi-graphql.netlify.app
https
.netlify/functions/index
POST
false
false
true
false
${__FileToString(your-file-path,,)}
true
false
saveConfig
true
true
true
true
true
true
true
true
false
true
true
false
false
false
true
false
false
false
true
0
true
true
true
true
true
true
````
Severity: normal
OS: Linux
Contributor guide
Assessment
This issue has not been assessed yet.