Gatling response body is Binary Content and doesn't tell the details of a 400 error

I’m using Gatling community version 9 with Java 17 to send a GraphQL request with some certificate data and got a 400, enabled debugging but the response body is binary content and can’t see the details of what is wrong. Here is the output from the run

HTTP request:
POST http://localhost:9091/query
accept: */*
user-agent: Gatling/Performance Test
Content-Type: application/json;
Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjBDNEM5NTVFNjM2OEFBODNENzg2QjdGMUMxNjk...8y6LHxNVAmuxSpoYG2fnhTbm8jEXV3a3cueHPzoxR4zy7GFQgYK69rbU6s4SE4a72ecWD9hGo6GwWv0gpa5M2OzA

host: localhost:9091
content-length: 1296
body:StringChunksRequestBody{charset=UTF-8, content={"query" : "mutation {certificateSigningRequest(input: {request: \"-----BEGIN CERTIFICATE REQUEST-----\\nMIIDITCCAgkCAQAwezELMAkGA1UEBhMCQkcxDjAMBgNVBAgTBVNvZmlhMQ4wDAYDVQQHEwVTb2ZpYTEPMA0GA1UEChMGVmVuYWZpMQswCQYDVQQLEwJRQ...LJbqxMuiTW0AnJri+3FOvpizjIIuE77EV6sD3WX+bGiPOoY0+Pv8ek3QIVhBieQg1rEGC9bQh5Ii1wuvjXgzETS0HNEgWYCBFES6UQUEQWKcvr+LR3XuBiw==\\n-----END CERTIFICATE REQUEST-----\", policyName: \"policy-xyz\",validityPeriod: \"P2D\"}) {certificateChain}}"}}

HTTP response:
400 Bad Request

I’m using StringBody() in Java like this

.exec(http("Create Signing Request")
          .header("Content-Type", "application/json")
          .header("Authorization","Bearer " + Token)
          .body(StringBody("{\"query\" : \"mutation {certificateSigningRequest(input: {request: " + CSR + ", policyName: \\\"policy-xyz\\\",validityPeriod: \\\"P2D\\\"}) {certificateChain}}\"}"))

Token and CSR are passed in variables, if I pass the same request body from Gatling output to curl, the curl request is successful.
Is there a way to see the details of the 400 error?
Thank you!

Hi @Peter1,

Without knowing the server, it will be hard to anybody to tell you why you receive a 400 Bad Request response.

Here the things that come in mind:

  • First: ensure that your body is valid. Try sending the exact same content with another tool (curl?)
  • Double/Triple check your escapes
  • Ensure you have a valid Token (some server may return a 400 response for invalid or malformed token).

Or help us to help you providing a full reproducer.


1 Like

Hi @sbrevet

Thanks a lot for the quick response!Yes, I started from curl with the Token and request body, after curl worked I then moved to Gatling with the Token and right request body for curl and ran into the issue with Gatling. Unfortunately the server is not easily reproducible in another env.
Just don’t know what Gatling expect on the body in terms of quotes and escape, in Scala we have toJson with StringBody, in Java, it doesn’t look we need something like toJson, right?Also don’t understand why the response body is binary. I’ll check more on the escape and may try ElFileBody.


Hi @sbrevet

My bad, the problem is from the baseURL, I’m supposedly to use https but mistakenly used http. After changed to https, it worked. Sorry about that, Gatling is solid!
Thank you!


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.