I am having error “ERROR 4495 — [-8080-exec-1395] g.k.servlet.AbstractGraphQLHttpServlet : Error executing GraphQL request!” while i am running a robot framework script. Here is the simple script for API test to send a request and print the content of the response:
I would say the query / body is incorrect. Is what you posted the exact same as your source code? Note that in Robot Framework syntax, you don’t need to quote strings. In the ${Body} I see some quotes that probably do not belong there. Also, the header indicates that you’re sending json, but you post ‘data’, not ‘json’…and the ${Body} is not a dictionary / json string.
I am trying to send graphql query to the server. Server cannot read this query. However, when I send this using POSTMAN, it returns me a response. Should I send json or graphql query. ${Body} is just a variable where i am trying to store the query. Please let me know if I am wrong or what should do?
If you have a working JSON body that you can send using Postman or similar tool, you should create a dictionary in Robot Framework with the same content and send that. You might be able to check the exact http request being send in Postman. What you send from RF should be the same.
It only accepts POST requests with a query string in the request body. With this type of setup, we are seeing problems of caching GraphQL requests with service.
*** Variables ***
*** Test Cases ***
Do a POST Request and validate the response code, response body, and response headers
Create Session mysession http://127.0.0.1:8000
${file_name}= Get Binary File ${CURDIR}\\test.json
&{body}= create dictionary query= query { places { name } }
&{header}= create dictionary Content-Type=application/json
log to console ${file_name}
${response}= POST On Session mysession / data=${file_name} headers=${header}
log to console ${response}
Status Should Be 200 ${response}
Data file: test.json
query {
places {
name
}
}
The error occurred:
HTTPError: 400 Client Error: Bad Request for url: http://127.0.0.1:8000/
Do you guys have any idea on it please let me know.
Many thanks
You should inspect the body of the 400 response, that may provide a hint as to what exactly is wrong with the request you’ve constructed. If there’s no more information in the response, talk to your developers since you may have to look at backend logs to figure out what’s wrong.